001package org.apache.maven.model.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 POM due to invalid syntax (e.g. non-wellformed XML or unknown elements). 026 * 027 * @author Benjamin Bentmann 028 */ 029public class ModelParseException 030 extends IOException 031{ 032 033 /** 034 * The one-based index of the line containing the error. 035 */ 036 private final int lineNumber; 037 038 /** 039 * The one-based index of the column containing the error. 040 */ 041 private final int columnNumber; 042 043 /** 044 * Creates a new parser exception with the specified details. 045 * 046 * @param message The error message, may be {@code null}. 047 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 048 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 049 */ 050 public ModelParseException( String message, int lineNumber, int columnNumber ) 051 { 052 super( message ); 053 this.lineNumber = lineNumber; 054 this.columnNumber = columnNumber; 055 } 056 057 /** 058 * Creates a new parser exception with the specified details. 059 * 060 * @param message The error message, may be {@code null}. 061 * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown. 062 * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown. 063 * @param cause The nested cause of this error, may be {@code null}. 064 */ 065 public ModelParseException( String message, int lineNumber, int columnNumber, Throwable cause ) 066 { 067 super( message ); 068 initCause( cause ); 069 this.lineNumber = lineNumber; 070 this.columnNumber = columnNumber; 071 } 072 073 /** 074 * Gets the one-based index of the line containing the error. 075 * 076 * @return The one-based index of the line containing the error or a non-positive value if unknown. 077 */ 078 public int getLineNumber() 079 { 080 return lineNumber; 081 } 082 083 /** 084 * Gets the one-based index of the column containing the error. 085 * 086 * @return The one-based index of the column containing the error or non-positive value if unknown. 087 */ 088 public int getColumnNumber() 089 { 090 return columnNumber; 091 } 092 093}