@@ -682,7 +682,7 @@ protected void _reportUnexpectedChar(int ch, String comment) throws JsonParseExc
682
682
if (comment != null ) {
683
683
msg += ": " +comment ;
684
684
}
685
- throw _constructReadException (msg , currentLocation ());
685
+ throw _constructReadException (msg , _currentLocationMinusOne ());
686
686
}
687
687
688
688
/**
@@ -698,7 +698,7 @@ protected <T> T _reportUnexpectedNumberChar(int ch, String comment) throws JsonP
698
698
if (comment != null ) {
699
699
msg += ": " +comment ;
700
700
}
701
- throw _constructReadException (msg , currentLocation ());
701
+ throw _constructReadException (msg , _currentLocationMinusOne ());
702
702
}
703
703
704
704
@ Deprecated // @since 2.14
@@ -722,6 +722,23 @@ protected final JsonParseException _constructError(String msg, Throwable t) {
722
722
return _constructReadException (msg , t );
723
723
}
724
724
725
+ /**
726
+ * Factory method used to provide location for cases where we must read
727
+ * and consume a single "wrong" character (to possibly allow error recovery),
728
+ * but need to report accurate location for that character: if so, the
729
+ * current location is past location we want, and location we want will be
730
+ * "one location earlier".
731
+ *<p>
732
+ * Default implementation simply returns {@link #currentLocation()}
733
+ *
734
+ * @since 2.17
735
+ *
736
+ * @return Same as {@link #currentLocation()} except offset by -1
737
+ */
738
+ protected JsonLocation _currentLocationMinusOne () {
739
+ return currentLocation ();
740
+ }
741
+
725
742
protected final static String _getCharDesc (int ch )
726
743
{
727
744
char c = (char ) ch ;
0 commit comments