Skip to content

Commit 10753a0

Browse files
committed
Minor refactoring for error handling
1 parent b3706eb commit 10753a0

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORParser.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,7 +2500,7 @@ private final String _finishLongText(int len) throws IOException
25002500
break;
25012501
default:
25022502
// Is this good enough error message?
2503-
_reportInvalidChar(c);
2503+
_reportInvalidInitial(c);
25042504
}
25052505
// Need more room?
25062506
if (outPtr >= outEnd) {
@@ -2603,7 +2603,7 @@ private final void _finishChunkedText() throws IOException
26032603
break;
26042604
default:
26052605
// Is this good enough error message?
2606-
_reportInvalidChar(c);
2606+
_reportInvalidInitial(c);
26072607
}
26082608
// Need more room?
26092609
if (outPtr >= outEnd) {
@@ -3833,7 +3833,7 @@ protected void _invalidToken(int ch) throws JsonParseException {
38333833
throw _constructError("Invalid CBOR value token (first byte): 0x"+Integer.toHexString(ch));
38343834
}
38353835

3836-
protected void _reportUnexpectedBreak() throws IOException {
3836+
protected <T> T _reportUnexpectedBreak() throws IOException {
38373837
if (_streamReadContext.inRoot()) {
38383838
throw _constructError("Unexpected Break (0xFF) token in Root context");
38393839
}
@@ -3842,14 +3842,6 @@ protected void _reportUnexpectedBreak() throws IOException {
38423842
+(_streamReadContext.inObject() ? "Object" : "Array" ));
38433843
}
38443844

3845-
protected void _reportInvalidChar(int c) throws JsonParseException {
3846-
// Either invalid WS or illegal UTF-8 start char
3847-
if (c < ' ') {
3848-
_throwInvalidSpace(c);
3849-
}
3850-
_reportInvalidInitial(c);
3851-
}
3852-
38533845
protected void _reportInvalidInitial(int mask) throws JsonParseException {
38543846
_reportError("Invalid UTF-8 start byte 0x"+Integer.toHexString(mask));
38553847
}

smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileParser.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2582,7 +2582,7 @@ private final void _decodeLongUnicodeValue() throws IOException
25822582
break;
25832583
default:
25842584
// Is this good enough error message?
2585-
_reportInvalidChar(c);
2585+
_reportInvalidInitial(c);
25862586
}
25872587
// Need more room?
25882588
if (outPtr >= outBuf.length) {
@@ -3053,15 +3053,6 @@ protected void _reportInvalidSharedStringValue(int index) throws IOException
30533053
_reportError("Invalid shared text value reference "+index+"; only got "+_seenStringValueCount+" names in buffer (invalid content)");
30543054
}
30553055

3056-
protected void _reportInvalidChar(int c) throws JsonParseException
3057-
{
3058-
// Either invalid WS or illegal UTF-8 start char
3059-
if (c < ' ') {
3060-
_throwInvalidSpace(c);
3061-
}
3062-
_reportInvalidInitial(c);
3063-
}
3064-
30653056
protected void _reportInvalidInitial(int mask) throws JsonParseException {
30663057
_reportError("Invalid UTF-8 start byte 0x"+Integer.toHexString(mask));
30673058
}

0 commit comments

Comments
 (0)