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