Browse files

Fix a few exceptions that don't generate ruby backtraces before getti…

…ng thrown.
  • Loading branch information...
1 parent 14b672e commit 852a031512c45457a00c22b94d1a0b95ab4d7b22 @headius headius committed Aug 20, 2010
Showing with 18 additions and 6 deletions.
  1. +15 −5 src/org/jruby/Ruby.java
  2. +3 −1 src/org/jruby/RubyKernel.java
View
20 src/org/jruby/Ruby.java
@@ -3206,7 +3206,9 @@ public RaiseException newIllegalSequence(String message) {
}
public RaiseException newNoMethodError(String message, String name, IRubyObject args) {
- return new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
+ RaiseException exception = new RaiseException(new RubyNoMethodError(this, getNoMethodError(), message, name, args), true);
+ exception.preRaise(getCurrentContext());
+ return exception;
}
public RaiseException newNameError(String message, String name) {
@@ -3221,20 +3223,26 @@ public RaiseException newNameError(String message, String name, Throwable origEx
if (printWhenVerbose && origException != null && this.isVerbose()) {
origException.printStackTrace(getErrorStream());
}
- return new RaiseException(new RubyNameError(
+
+ RaiseException exception = new RaiseException(new RubyNameError(
this, getNameError(), message, name), false);
+ exception.preRaise(getCurrentContext());
+
+ return exception;
}
public RaiseException newLocalJumpError(RubyLocalJumpError.Reason reason, IRubyObject exitValue, String message) {
- return new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), message, reason, exitValue), true);
+ RaiseException exception = new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), message, reason, exitValue), true);
+ exception.preRaise(getCurrentContext());
+ return exception;
}
public RaiseException newLocalJumpErrorNoBlock() {
return newLocalJumpError(RubyLocalJumpError.Reason.NOREASON, getNil(), "no block given");
}
public RaiseException newRedoLocalJumpError() {
- return new RaiseException(new RubyLocalJumpError(this, getLocalJumpError(), "unexpected redo", RubyLocalJumpError.Reason.REDO, getNil()), true);
+ return newLocalJumpError(RubyLocalJumpError.Reason.REDO, getNil(), "unexpected redo");
}
public RaiseException newLoadError(String message) {
@@ -3262,7 +3270,9 @@ public RaiseException newSystemStackError(String message, StackOverflowError soe
}
public RaiseException newSystemExit(int status) {
- return new RaiseException(RubySystemExit.newInstance(this, status));
+ RaiseException exception = new RaiseException(RubySystemExit.newInstance(this, status));
+ exception.preRaise(getCurrentContext());
+ return exception;
}
public RaiseException newIOError(String message) {
View
4 src/org/jruby/RubyKernel.java
@@ -268,7 +268,9 @@ private static IRubyObject methodMissing(ThreadContext context, IRubyObject recv
exArgs = new IRubyObject[]{msg, symbol};
}
- throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
+ RaiseException exception = new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
+ exception.preRaise(context);
+ throw exception;
}
@JRubyMethod(name = "open", required = 1, optional = 2, frame = true, module = true, visibility = PRIVATE)

0 comments on commit 852a031

Please sign in to comment.