@@ -273,20 +273,16 @@ public String getText() throws IOException
273273 case VALUE_STRING :
274274 try {
275275 return _reader .stringValue ();
276- } catch (UnknownSymbolException e ) {
276+ } catch (UnknownSymbolException
277277 // stringValue() will throw an UnknownSymbolException if we're
278278 // trying to get the text for a symbol id that cannot be resolved.
279279 // stringValue() has an assert statement which could throw an
280- throw _constructError (e .getMessage (), e );
281- } catch (AssertionError | NullPointerException e ) {
280+ | AssertionError | NullPointerException e
282281 // AssertionError if we're trying to get the text with a symbol
283282 // id less than or equals to 0.
284283 // NullPointerException may also be thrown on invalid data
285- String msg = e .getMessage ();
286- if (msg == null ) {
287- msg = "UNKNOWN ROOT CAUSE" ;
288- }
289- throw _constructError ("Internal `IonReader` error: " +msg , e );
284+ ) {
285+ return _reportCorruptContent (e );
290286 }
291287 case VALUE_NUMBER_INT :
292288 case VALUE_NUMBER_FLOAT :
@@ -576,8 +572,11 @@ public JsonToken nextToken() throws IOException
576572 type = _reader .next ();
577573 } catch (IonException e ) {
578574 return _reportCorruptContent (e );
575+
576+ } catch (IndexOutOfBoundsException | AssertionError e ) {
579577 // [dataformats-binary#420]: IonJava leaks IOOBEs so:
580- } catch (IndexOutOfBoundsException e ) {
578+ // [dataformats-binary#432]: AssertionError if we're trying to get the text
579+ // with a symbol id less than or equals to 0.
581580 return _reportCorruptContent (e );
582581 }
583582 if (type == null ) {
@@ -717,17 +716,25 @@ protected void _handleEOF() throws JsonParseException
717716 }
718717 }
719718
720- private <T > T _reportCorruptContent (Exception e ) throws IOException
719+ private <T > T _reportCorruptContent (Throwable e ) throws IOException
721720 {
722- final String msg = String .format ("Corrupt content to decode; underlying failure: (%s) %s" ,
723- e .getClass ().getName (), e .getMessage ());
721+ String origMsg = e .getMessage ();
722+ if (origMsg == null ) {
723+ origMsg = "[no exception message]" ;
724+ }
725+ final String msg = String .format ("Corrupt content to decode; underlying `IonReader` problem: (%s) %s" ,
726+ e .getClass ().getName (), origMsg );
724727 throw _constructError (msg , e );
725728 }
726729
727- private <T > T _reportCorruptNumber (Exception e ) throws IOException
730+ private <T > T _reportCorruptNumber (Throwable e ) throws IOException
728731 {
729- final String msg = String .format ("Corrupt Number value to decode; underlying failure: (%s) %s" ,
730- e .getClass ().getName (), e .getMessage ());
732+ String origMsg = e .getMessage ();
733+ if (origMsg == null ) {
734+ origMsg = "[no exception message]" ;
735+ }
736+ final String msg = String .format ("Corrupt Number value to decode; underlying `IonReader` problem: (%s) %s" ,
737+ e .getClass ().getName (), origMsg );
731738 throw _constructError (msg , e );
732739 }
733740
0 commit comments