Skip to content

Commit 16a86d7

Browse files
committed
Pass in the throwable that caused the error.
1 parent dfa651e commit 16a86d7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

JSONTokener.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public String nextString(char quote) throws JSONException {
281281
try {
282282
sb.append((char)Integer.parseInt(this.next(4), 16));
283283
} catch (NumberFormatException e) {
284-
throw this.syntaxError("Illegal escape.");
284+
throw this.syntaxError("Illegal escape.", e);
285285
}
286286
break;
287287
case '"':
@@ -437,6 +437,16 @@ public JSONException syntaxError(String message) {
437437
return new JSONException(message + this.toString());
438438
}
439439

440+
/**
441+
* Make a JSONException to signal a syntax error.
442+
*
443+
* @param message The error message.
444+
* @param causedBy The throwable that caused the error.
445+
* @return A JSONException object, suitable for throwing
446+
*/
447+
public JSONException syntaxError(String message, Throwable causedBy) {
448+
return new JSONException(message + this.toString(), causedBy);
449+
}
440450

441451
/**
442452
* Make a printable string of this JSONTokener.

0 commit comments

Comments
 (0)