2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.tools.ant;
21
* Signals an error condition during a build
23
public class BuildException extends RuntimeException {
25
private static final long serialVersionUID = -5419014565354664240L;
27
/** Location in the build file where the exception occurred */
28
private Location location = Location.UNKNOWN_LOCATION;
31
* Constructs a build exception with no descriptive information.
33
public BuildException() {
38
* Constructs an exception with the given descriptive message.
40
* @param message A description of or information about the exception.
41
* Should not be <code>null</code>.
43
public BuildException(String message) {
48
* Constructs an exception with the given message and exception as
51
* @param message A description of or information about the exception.
52
* Should not be <code>null</code> unless a cause is specified.
53
* @param cause The exception that might have caused this one.
54
* May be <code>null</code>.
56
public BuildException(String message, Throwable cause) {
62
* Constructs an exception with the given message and exception as
63
* a root cause and a location in a file.
65
* @param msg A description of or information about the exception.
66
* Should not be <code>null</code> unless a cause is specified.
67
* @param cause The exception that might have caused this one.
68
* May be <code>null</code>.
69
* @param location The location in the project file where the error
70
* occurred. Must not be <code>null</code>.
72
public BuildException(String msg, Throwable cause, Location location) {
74
this.location = location;
78
* Constructs an exception with the given exception as a root cause.
80
* @param cause The exception that might have caused this one.
81
* Should not be <code>null</code>.
83
public BuildException(Throwable cause) {
88
* Constructs an exception with the given descriptive message and a
91
* @param message A description of or information about the exception.
92
* Should not be <code>null</code>.
93
* @param location The location in the project file where the error
94
* occurred. Must not be <code>null</code>.
96
public BuildException(String message, Location location) {
98
this.location = location;
102
* Constructs an exception with the given exception as
103
* a root cause and a location in a file.
105
* @param cause The exception that might have caused this one.
106
* Should not be <code>null</code>.
107
* @param location The location in the project file where the error
108
* occurred. Must not be <code>null</code>.
110
public BuildException(Throwable cause, Location location) {
112
this.location = location;
116
* Returns the nested exception, if any.
118
* @return the nested exception, or <code>null</code> if no
119
* exception is associated with this one
120
* @deprecated Use {@link #getCause} instead.
122
public Throwable getException() {
127
* Returns the location of the error and the error message.
129
* @return the location of the error and the error message
131
public String toString() {
132
return location.toString() + getMessage();
136
* Sets the file location where the error occurred.
138
* @param location The file location where the error occurred.
139
* Must not be <code>null</code>.
141
public void setLocation(Location location) {
142
this.location = location;
146
* Returns the file location where the error occurred.
148
* @return the file location where the error occurred.
150
public Location getLocation() {
2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.tools.ant;
21
* Signals an error condition during a build
23
public class BuildException extends RuntimeException {
25
private static final long serialVersionUID = -5419014565354664240L;
27
/** Location in the build file where the exception occurred */
28
private Location location = Location.UNKNOWN_LOCATION;
31
* Constructs a build exception with no descriptive information.
33
public BuildException() {
38
* Constructs an exception with the given descriptive message.
40
* @param message A description of or information about the exception.
41
* Should not be <code>null</code>.
43
public BuildException(String message) {
48
* Constructs an exception with the given message and exception as
51
* @param message A description of or information about the exception.
52
* Should not be <code>null</code> unless a cause is specified.
53
* @param cause The exception that might have caused this one.
54
* May be <code>null</code>.
56
public BuildException(String message, Throwable cause) {
57
super(message, cause);
61
* Constructs an exception with the given message and exception as
62
* a root cause and a location in a file.
64
* @param msg A description of or information about the exception.
65
* Should not be <code>null</code> unless a cause is specified.
66
* @param cause The exception that might have caused this one.
67
* May be <code>null</code>.
68
* @param location The location in the project file where the error
69
* occurred. Must not be <code>null</code>.
71
public BuildException(String msg, Throwable cause, Location location) {
73
this.location = location;
77
* Constructs an exception with the given exception as a root cause.
79
* @param cause The exception that might have caused this one.
80
* Should not be <code>null</code>.
82
public BuildException(Throwable cause) {
87
* Constructs an exception with the given descriptive message and a
90
* @param message A description of or information about the exception.
91
* Should not be <code>null</code>.
92
* @param location The location in the project file where the error
93
* occurred. Must not be <code>null</code>.
95
public BuildException(String message, Location location) {
97
this.location = location;
101
* Constructs an exception with the given exception as
102
* a root cause and a location in a file.
104
* @param cause The exception that might have caused this one.
105
* Should not be <code>null</code>.
106
* @param location The location in the project file where the error
107
* occurred. Must not be <code>null</code>.
109
public BuildException(Throwable cause, Location location) {
111
this.location = location;
115
* Returns the nested exception, if any.
117
* @return the nested exception, or <code>null</code> if no
118
* exception is associated with this one
119
* @deprecated Use {@link #getCause} instead.
121
public Throwable getException() {
126
* Returns the location of the error and the error message.
128
* @return the location of the error and the error message
130
public String toString() {
131
return location.toString() + getMessage();
135
* Sets the file location where the error occurred.
137
* @param location The file location where the error occurred.
138
* Must not be <code>null</code>.
140
public void setLocation(Location location) {
141
this.location = location;
145
* Returns the file location where the error occurred.
147
* @return the file location where the error occurred.
149
public Location getLocation() {