mirror of
https://github.com/fankes/JSON-java-compat.git
synced 2025-09-07 19:14:15 +08:00
Merge pull request #236 from madsager/master
Make nextString throw a JSONException instead of a NumberFormatExcept…
This commit is contained in:
@@ -278,7 +278,11 @@ public class JSONTokener {
|
|||||||
sb.append('\r');
|
sb.append('\r');
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
sb.append((char)Integer.parseInt(this.next(4), 16));
|
try {
|
||||||
|
sb.append((char)Integer.parseInt(this.next(4), 16));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw this.syntaxError("Illegal escape.", e);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
case '\'':
|
case '\'':
|
||||||
@@ -433,6 +437,16 @@ public class JSONTokener {
|
|||||||
return new JSONException(message + this.toString());
|
return new JSONException(message + this.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a JSONException to signal a syntax error.
|
||||||
|
*
|
||||||
|
* @param message The error message.
|
||||||
|
* @param causedBy The throwable that caused the error.
|
||||||
|
* @return A JSONException object, suitable for throwing
|
||||||
|
*/
|
||||||
|
public JSONException syntaxError(String message, Throwable causedBy) {
|
||||||
|
return new JSONException(message + this.toString(), causedBy);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a printable string of this JSONTokener.
|
* Make a printable string of this JSONTokener.
|
||||||
|
Reference in New Issue
Block a user