View Javadoc
1   package org.apache.maven.toolchain.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 toolchains due to invalid syntax (e.g. non-wellformed XML or unknown elements).
26   *
27   * @author Robert Scholte
28   * @since 3.3.0
29   */
30  public class ToolchainsParseException
31      extends IOException
32  {
33  
34      /**
35       * The one-based index of the line containing the error.
36       */
37      private final int lineNumber;
38  
39      /**
40       * The one-based index of the column containing the error.
41       */
42      private final int columnNumber;
43  
44      /**
45       * Creates a new parser exception with the specified details.
46       *
47       * @param message The error message, may be {@code null}.
48       * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown.
49       * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown.
50       */
51      public ToolchainsParseException( String message, int lineNumber, int columnNumber )
52      {
53          super( message );
54          this.lineNumber = lineNumber;
55          this.columnNumber = columnNumber;
56      }
57  
58      /**
59       * Creates a new parser exception with the specified details.
60       *
61       * @param message The error message, may be {@code null}.
62       * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown.
63       * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown.
64       * @param cause The nested cause of this error, may be {@code null}.
65       */
66      public ToolchainsParseException( String message, int lineNumber, int columnNumber, Throwable cause )
67      {
68          super( message );
69          initCause( cause );
70          this.lineNumber = lineNumber;
71          this.columnNumber = columnNumber;
72      }
73  
74      /**
75       * Gets the one-based index of the line containing the error.
76       *
77       * @return The one-based index of the line containing the error or a non-positive value if unknown.
78       */
79      public int getLineNumber()
80      {
81          return lineNumber;
82      }
83  
84      /**
85       * Gets the one-based index of the column containing the error.
86       *
87       * @return The one-based index of the column containing the error or non-positive value if unknown.
88       */
89      public int getColumnNumber()
90      {
91          return columnNumber;
92      }
93  
94  }