~ubuntu-branches/ubuntu/utopic/ant/utopic

« back to all changes in this revision

Viewing changes to src/main/org/apache/tools/ant/BuildException.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2013-05-15 16:19:56 UTC
  • mfrom: (1.3.3) (5.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130515161956-vd4ht4u68rok767b
Tags: 1.9.1-1
* New upstream release
  - Refreshed the patches
  - Removed patch 0001-detect-classpath-based-JVM (merged upstream)
* Enabled hardening for the -gcj packages
* Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
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
8
 
 *
9
 
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
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.
16
 
 *
17
 
 */
18
 
package org.apache.tools.ant;
19
 
 
20
 
/**
21
 
 * Signals an error condition during a build
22
 
 */
23
 
public class BuildException extends RuntimeException {
24
 
 
25
 
    private static final long serialVersionUID = -5419014565354664240L;
26
 
 
27
 
    /** Location in the build file where the exception occurred */
28
 
    private Location location = Location.UNKNOWN_LOCATION;
29
 
 
30
 
    /**
31
 
     * Constructs a build exception with no descriptive information.
32
 
     */
33
 
    public BuildException() {
34
 
        super();
35
 
    }
36
 
 
37
 
    /**
38
 
     * Constructs an exception with the given descriptive message.
39
 
     *
40
 
     * @param message A description of or information about the exception.
41
 
     *            Should not be <code>null</code>.
42
 
     */
43
 
    public BuildException(String message) {
44
 
        super(message);
45
 
    }
46
 
 
47
 
    /**
48
 
     * Constructs an exception with the given message and exception as
49
 
     * a root cause.
50
 
     *
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>.
55
 
     */
56
 
    public BuildException(String message, Throwable cause) {
57
 
        super(message);
58
 
        initCause(cause);
59
 
    }
60
 
 
61
 
    /**
62
 
     * Constructs an exception with the given message and exception as
63
 
     * a root cause and a location in a file.
64
 
     *
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>.
71
 
     */
72
 
    public BuildException(String msg, Throwable cause, Location location) {
73
 
        this(msg, cause);
74
 
        this.location = location;
75
 
    }
76
 
 
77
 
    /**
78
 
     * Constructs an exception with the given exception as a root cause.
79
 
     *
80
 
     * @param cause The exception that might have caused this one.
81
 
     *              Should not be <code>null</code>.
82
 
     */
83
 
    public BuildException(Throwable cause) {
84
 
        super(cause);
85
 
    }
86
 
 
87
 
    /**
88
 
     * Constructs an exception with the given descriptive message and a
89
 
     * location in a file.
90
 
     *
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>.
95
 
     */
96
 
    public BuildException(String message, Location location) {
97
 
        super(message);
98
 
        this.location = location;
99
 
    }
100
 
 
101
 
    /**
102
 
     * Constructs an exception with the given exception as
103
 
     * a root cause and a location in a file.
104
 
     *
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>.
109
 
     */
110
 
    public BuildException(Throwable cause, Location location) {
111
 
        this(cause);
112
 
        this.location = location;
113
 
    }
114
 
 
115
 
    /**
116
 
     * Returns the nested exception, if any.
117
 
     *
118
 
     * @return the nested exception, or <code>null</code> if no
119
 
     *         exception is associated with this one
120
 
     * @deprecated Use {@link #getCause} instead.
121
 
     */
122
 
    public Throwable getException() {
123
 
        return getCause();
124
 
    }
125
 
 
126
 
    /**
127
 
     * Returns the location of the error and the error message.
128
 
     *
129
 
     * @return the location of the error and the error message
130
 
     */
131
 
    public String toString() {
132
 
        return location.toString() + getMessage();
133
 
    }
134
 
 
135
 
    /**
136
 
     * Sets the file location where the error occurred.
137
 
     *
138
 
     * @param location The file location where the error occurred.
139
 
     *                 Must not be <code>null</code>.
140
 
     */
141
 
    public void setLocation(Location location) {
142
 
        this.location = location;
143
 
    }
144
 
 
145
 
    /**
146
 
     * Returns the file location where the error occurred.
147
 
     *
148
 
     * @return the file location where the error occurred.
149
 
     */
150
 
    public Location getLocation() {
151
 
        return location;
152
 
    }
153
 
 
154
 
}
 
1
/*
 
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
 
8
 *
 
9
 *      http://www.apache.org/licenses/LICENSE-2.0
 
10
 *
 
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.
 
16
 *
 
17
 */
 
18
package org.apache.tools.ant;
 
19
 
 
20
/**
 
21
 * Signals an error condition during a build
 
22
 */
 
23
public class BuildException extends RuntimeException {
 
24
 
 
25
    private static final long serialVersionUID = -5419014565354664240L;
 
26
 
 
27
    /** Location in the build file where the exception occurred */
 
28
    private Location location = Location.UNKNOWN_LOCATION;
 
29
 
 
30
    /**
 
31
     * Constructs a build exception with no descriptive information.
 
32
     */
 
33
    public BuildException() {
 
34
        super();
 
35
    }
 
36
 
 
37
    /**
 
38
     * Constructs an exception with the given descriptive message.
 
39
     *
 
40
     * @param message A description of or information about the exception.
 
41
     *            Should not be <code>null</code>.
 
42
     */
 
43
    public BuildException(String message) {
 
44
        super(message);
 
45
    }
 
46
 
 
47
    /**
 
48
     * Constructs an exception with the given message and exception as
 
49
     * a root cause.
 
50
     *
 
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>.
 
55
     */
 
56
    public BuildException(String message, Throwable cause) {
 
57
        super(message, cause);
 
58
    }
 
59
 
 
60
    /**
 
61
     * Constructs an exception with the given message and exception as
 
62
     * a root cause and a location in a file.
 
63
     *
 
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>.
 
70
     */
 
71
    public BuildException(String msg, Throwable cause, Location location) {
 
72
        this(msg, cause);
 
73
        this.location = location;
 
74
    }
 
75
 
 
76
    /**
 
77
     * Constructs an exception with the given exception as a root cause.
 
78
     *
 
79
     * @param cause The exception that might have caused this one.
 
80
     *              Should not be <code>null</code>.
 
81
     */
 
82
    public BuildException(Throwable cause) {
 
83
        super(cause);
 
84
    }
 
85
 
 
86
    /**
 
87
     * Constructs an exception with the given descriptive message and a
 
88
     * location in a file.
 
89
     *
 
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>.
 
94
     */
 
95
    public BuildException(String message, Location location) {
 
96
        super(message);
 
97
        this.location = location;
 
98
    }
 
99
 
 
100
    /**
 
101
     * Constructs an exception with the given exception as
 
102
     * a root cause and a location in a file.
 
103
     *
 
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>.
 
108
     */
 
109
    public BuildException(Throwable cause, Location location) {
 
110
        this(cause);
 
111
        this.location = location;
 
112
    }
 
113
 
 
114
    /**
 
115
     * Returns the nested exception, if any.
 
116
     *
 
117
     * @return the nested exception, or <code>null</code> if no
 
118
     *         exception is associated with this one
 
119
     * @deprecated Use {@link #getCause} instead.
 
120
     */
 
121
    public Throwable getException() {
 
122
        return getCause();
 
123
    }
 
124
 
 
125
    /**
 
126
     * Returns the location of the error and the error message.
 
127
     *
 
128
     * @return the location of the error and the error message
 
129
     */
 
130
    public String toString() {
 
131
        return location.toString() + getMessage();
 
132
    }
 
133
 
 
134
    /**
 
135
     * Sets the file location where the error occurred.
 
136
     *
 
137
     * @param location The file location where the error occurred.
 
138
     *                 Must not be <code>null</code>.
 
139
     */
 
140
    public void setLocation(Location location) {
 
141
        this.location = location;
 
142
    }
 
143
 
 
144
    /**
 
145
     * Returns the file location where the error occurred.
 
146
     *
 
147
     * @return the file location where the error occurred.
 
148
     */
 
149
    public Location getLocation() {
 
150
        return location;
 
151
    }
 
152
 
 
153
}