diff --git a/src/main/java/org/jruby/ext/openssl/ASN1.java b/src/main/java/org/jruby/ext/openssl/ASN1.java index fbe08bb9..a4c52f47 100644 --- a/src/main/java/org/jruby/ext/openssl/ASN1.java +++ b/src/main/java/org/jruby/ext/openssl/ASN1.java @@ -1127,12 +1127,11 @@ public static IRubyObject decode(final ThreadContext context, return decodeImpl(context, (RubyModule) self, obj); } catch (IOException e) { - //throw context.runtime.newIOErrorFromException(e); - throw newASN1Error(context.runtime, e.getMessage()); + throw newASN1Error(context.runtime, e); } catch (IllegalArgumentException e) { debugStackTrace(context.runtime, e); - throw context.runtime.newArgumentError(e.getMessage()); + throw (RaiseException) context.runtime.newArgumentError(e.getMessage()).initCause(e); } catch (RuntimeException e) { @@ -1212,8 +1211,7 @@ public static IRubyObject decode_all(final ThreadContext context, arr.append( decodeImpl(context, ASN1, in) ); } catch (IOException e) { - //throw context.runtime.newIOErrorFromException(e); - throw newASN1Error(context.runtime, e.getMessage()); + throw newASN1Error(context.runtime, e); } catch (IllegalArgumentException e) { debugStackTrace(context.runtime, e); @@ -1233,6 +1231,10 @@ public static RaiseException newASN1Error(Ruby runtime, String message) { return Utils.newError(runtime, _ASN1(runtime).getClass("ASN1Error"), message, false); } + static RaiseException newASN1Error(Ruby runtime, Throwable ex) { + return (RaiseException) newASN1Error(runtime, ex.getMessage()).initCause(ex); + } + static RubyModule _ASN1(final Ruby runtime) { return (RubyModule) runtime.getModule("OpenSSL").getConstant("ASN1"); }