001package org.apache.maven.toolchain.io; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.IOException; 023 024/** 025 * Signals a failure to parse the toolchains due to invalid syntax (e.g. non-wellformed XML or unknown elements). 026 * 027 * @author Robert Scholte 028 * @since 3.3.0 029 */ 030public class ToolchainsParseException 031 extends IOException 032{ 033 034 /** 035 * The one-based index of the line containing the error. 036 */ 037 private final int lineNumber; 038 039 /** 040 * The one-based index of the column containing the error. 041 */ 042 private final int columnNumber; 043 044 /** 045 * Creates a new parser exception with the specified details. 046 * 047 * @param message The error message, may be {@code null}. 048 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 049 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 050 */ 051 public ToolchainsParseException( String message, int lineNumber, int columnNumber ) 052 { 053 super( message ); 054 this.lineNumber = lineNumber; 055 this.columnNumber = columnNumber; 056 } 057 058 /** 059 * Creates a new parser exception with the specified details. 060 * 061 * @param message The error message, may be {@code null}. 062 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 063 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 064 * @param cause The nested cause of this error, may be {@code null}. 065 */ 066 public ToolchainsParseException( String message, int lineNumber, int columnNumber, Throwable cause ) 067 { 068 super( message ); 069 initCause( cause ); 070 this.lineNumber = lineNumber; 071 this.columnNumber = columnNumber; 072 } 073 074 /** 075 * Gets the one-based index of the line containing the error. 076 * 077 * @return The one-based index of the line containing the error or a non-positive value if unknown. 078 */ 079 public int getLineNumber() 080 { 081 return lineNumber; 082 } 083 084 /** 085 * Gets the one-based index of the column containing the error. 086 * 087 * @return The one-based index of the column containing the error or non-positive value if unknown. 088 */ 089 public int getColumnNumber() 090 { 091 return columnNumber; 092 } 093 094}