@@ -1127,12 +1127,11 @@ public static IRubyObject decode(final ThreadContext context,
11271127 return decodeImpl (context , (RubyModule ) self , obj );
11281128 }
11291129 catch (IOException e ) {
1130- //throw context.runtime.newIOErrorFromException(e);
1131- throw newASN1Error (context .runtime , e .getMessage ());
1130+ throw newASN1Error (context .runtime , e );
11321131 }
11331132 catch (IllegalArgumentException e ) {
11341133 debugStackTrace (context .runtime , e );
1135- throw context .runtime .newArgumentError (e .getMessage ());
1134+ throw ( RaiseException ) context .runtime .newArgumentError (e .getMessage ()). initCause ( e );
11361135 }
11371136 catch (RuntimeException e ) {
11381137
@@ -1212,8 +1211,7 @@ public static IRubyObject decode_all(final ThreadContext context,
12121211 arr .append ( decodeImpl (context , ASN1 , in ) );
12131212 }
12141213 catch (IOException e ) {
1215- //throw context.runtime.newIOErrorFromException(e);
1216- throw newASN1Error (context .runtime , e .getMessage ());
1214+ throw newASN1Error (context .runtime , e );
12171215 }
12181216 catch (IllegalArgumentException e ) {
12191217 debugStackTrace (context .runtime , e );
@@ -1233,6 +1231,10 @@ public static RaiseException newASN1Error(Ruby runtime, String message) {
12331231 return Utils .newError (runtime , _ASN1 (runtime ).getClass ("ASN1Error" ), message , false );
12341232 }
12351233
1234+ static RaiseException newASN1Error (Ruby runtime , Throwable ex ) {
1235+ return (RaiseException ) newASN1Error (runtime , ex .getMessage ()).initCause (ex );
1236+ }
1237+
12361238 static RubyModule _ASN1 (final Ruby runtime ) {
12371239 return (RubyModule ) runtime .getModule ("OpenSSL" ).getConstant ("ASN1" );
12381240 }
0 commit comments