1 package org.apache.maven.settings.io; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.IOException; 23 24 /** 25 * Signals a failure to parse the settings due to invalid syntax (e.g. non-wellformed XML or unknown elements). 26 * 27 * @author Benjamin Bentmann 28 */ 29 public class SettingsParseException 30 extends IOException 31 { 32 33 /** 34 * The one-based index of the line containing the error. 35 */ 36 private final int lineNumber; 37 38 /** 39 * The one-based index of the column containing the error. 40 */ 41 private final int columnNumber; 42 43 /** 44 * Creates a new parser exception with the specified details. 45 * 46 * @param message The error message, may be {@code null}. 47 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 48 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 49 */ 50 public SettingsParseException( String message, int lineNumber, int columnNumber ) 51 { 52 super( message ); 53 this.lineNumber = lineNumber; 54 this.columnNumber = columnNumber; 55 } 56 57 /** 58 * Creates a new parser exception with the specified details. 59 * 60 * @param message The error message, may be {@code null}. 61 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 62 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 63 * @param cause The nested cause of this error, may be {@code null}. 64 */ 65 public SettingsParseException( String message, int lineNumber, int columnNumber, Throwable cause ) 66 { 67 super( message ); 68 initCause( cause ); 69 this.lineNumber = lineNumber; 70 this.columnNumber = columnNumber; 71 } 72 73 /** 74 * Gets the one-based index of the line containing the error. 75 * 76 * @return The one-based index of the line containing the error or a non-positive value if unknown. 77 */ 78 public int getLineNumber() 79 { 80 return lineNumber; 81 } 82 83 /** 84 * Gets the one-based index of the column containing the error. 85 * 86 * @return The one-based index of the column containing the error or non-positive value if unknown. 87 */ 88 public int getColumnNumber() 89 { 90 return columnNumber; 91 } 92 93 }