@@ -273,20 +273,16 @@ public String getText() throws IOException
273
273
case VALUE_STRING :
274
274
try {
275
275
return _reader .stringValue ();
276
- } catch (UnknownSymbolException e ) {
276
+ } catch (UnknownSymbolException
277
277
// stringValue() will throw an UnknownSymbolException if we're
278
278
// trying to get the text for a symbol id that cannot be resolved.
279
279
// stringValue() has an assert statement which could throw an
280
- throw _constructError (e .getMessage (), e );
281
- } catch (AssertionError | NullPointerException e ) {
280
+ | AssertionError | NullPointerException e
282
281
// AssertionError if we're trying to get the text with a symbol
283
282
// id less than or equals to 0.
284
283
// 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 );
290
286
}
291
287
case VALUE_NUMBER_INT :
292
288
case VALUE_NUMBER_FLOAT :
@@ -576,8 +572,11 @@ public JsonToken nextToken() throws IOException
576
572
type = _reader .next ();
577
573
} catch (IonException e ) {
578
574
return _reportCorruptContent (e );
575
+
576
+ } catch (IndexOutOfBoundsException | AssertionError e ) {
579
577
// [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.
581
580
return _reportCorruptContent (e );
582
581
}
583
582
if (type == null ) {
@@ -717,17 +716,25 @@ protected void _handleEOF() throws JsonParseException
717
716
}
718
717
}
719
718
720
- private <T > T _reportCorruptContent (Exception e ) throws IOException
719
+ private <T > T _reportCorruptContent (Throwable e ) throws IOException
721
720
{
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 );
724
727
throw _constructError (msg , e );
725
728
}
726
729
727
- private <T > T _reportCorruptNumber (Exception e ) throws IOException
730
+ private <T > T _reportCorruptNumber (Throwable e ) throws IOException
728
731
{
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 );
731
738
throw _constructError (msg , e );
732
739
}
733
740
0 commit comments