Skip to content

Commit b0a9507

Browse files
committed
Merge pull request stleary#159 from johnjaylward/FixExceptionInheritance
Properly overrides the Exception class.
2 parents 6757e04 + 1448163 commit b0a9507

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

JSONException.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,42 @@
44
* The JSONException is thrown by the JSON.org classes when things are amiss.
55
*
66
* @author JSON.org
7-
* @version 2014-05-03
7+
* @version 2015-10-14
88
*/
99
public class JSONException extends RuntimeException {
10+
/** Serialization ID */
1011
private static final long serialVersionUID = 0;
11-
private Throwable cause;
1212

1313
/**
1414
* Constructs a JSONException with an explanatory message.
1515
*
1616
* @param message
1717
* Detail about the reason for the exception.
1818
*/
19-
public JSONException(String message) {
20-
super(message);
19+
public JSONException(final String message) {
20+
super(message);
2121
}
2222

2323
/**
24-
* Constructs a new JSONException with the specified cause.
25-
* @param cause The cause.
24+
* Constructs a JSONException with an explanatory message and cause.
25+
*
26+
* @param message
27+
* Detail about the reason for the exception.
28+
* @param cause
29+
* The cause.
2630
*/
27-
public JSONException(Throwable cause) {
28-
super(cause.getMessage());
29-
this.cause = cause;
31+
public JSONException(final String message, final Throwable cause) {
32+
super(message, cause);
3033
}
3134

3235
/**
33-
* Returns the cause of this exception or null if the cause is nonexistent
34-
* or unknown.
35-
*
36-
* @return the cause of this exception or null if the cause is nonexistent
37-
* or unknown.
36+
* Constructs a new JSONException with the specified cause.
37+
*
38+
* @param cause
39+
* The cause.
3840
*/
39-
@Override
40-
public Throwable getCause() {
41-
return this.cause;
41+
public JSONException(final Throwable cause) {
42+
super(cause.getMessage(), cause);
4243
}
44+
4345
}

0 commit comments

Comments
 (0)