mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-03 11:25:30 -04:00
extend syntax error information
This commit is contained in:
parent
45dede448c
commit
30dc22790c
@ -299,7 +299,8 @@ public class JSONTokener {
|
|||||||
case 0:
|
case 0:
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
throw this.syntaxError("Unterminated string");
|
throw this.syntaxError("Unterminated string. " +
|
||||||
|
"Character with int code " + (int) c + " is not allowed within a quoted string.");
|
||||||
case '\\':
|
case '\\':
|
||||||
c = this.next();
|
c = this.next();
|
||||||
switch (c) {
|
switch (c) {
|
||||||
@ -322,7 +323,7 @@ public class JSONTokener {
|
|||||||
try {
|
try {
|
||||||
sb.append((char)Integer.parseInt(this.next(4), 16));
|
sb.append((char)Integer.parseInt(this.next(4), 16));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw this.syntaxError("Illegal escape.", e);
|
throw this.syntaxError("Illegal escape. \\u must be followed by a 4 digit number.", e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '"':
|
case '"':
|
||||||
@ -332,7 +333,7 @@ public class JSONTokener {
|
|||||||
sb.append(c);
|
sb.append(c);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw this.syntaxError("Illegal escape.");
|
throw this.syntaxError("Illegal escape. Escape sequence \\" + c + " is not valid.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -521,7 +522,7 @@ public class JSONTokener {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return " at " + this.index + " [character " + this.character + " line " +
|
return " at index: " + this.index + " [character number " + this.character + " in line " +
|
||||||
this.line + "]";
|
this.line + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user