@JRubyMethod(name = "message") public IRubyObject message(ThreadContext context) { return callMethod(context, "to_s"); }
@JRubyMethod(name = "message") public IRubyObject message(ThreadContext context) { return callMethod(context, "to_s"); }
@JRubyMethod(name = "message") public IRubyObject message(ThreadContext context) { return callMethod(context, "to_s"); }
@JRubyMethod(name = "message") public IRubyObject message(ThreadContext context) { return callMethod(context, "to_s"); }
@JRubyMethod(name = "to_str", compat = CompatVersion.RUBY1_8) public IRubyObject to_str(ThreadContext context) { return callMethod(context, "to_s"); }
@JRubyMethod(name = "to_str", compat = CompatVersion.RUBY1_8) public IRubyObject to_str(ThreadContext context) { return callMethod(context, "to_s"); }
private static IRubyObject raiseTimeoutError(ThreadContext context, RaiseException re) { Ruby runtime = context.runtime; return RubyKernel.raise( context, runtime.getKernel(), new IRubyObject[]{ runtime.getClassFromPath("Timeout::Error"), re.getException().callMethod(context, "message"), re.getException().callMethod(context, "backtrace")}, Block.NULL_BLOCK); } }
private static IRubyObject raiseTimeoutError(ThreadContext context, RaiseException re) { Ruby runtime = context.runtime; return RubyKernel.raise( context, runtime.getKernel(), new IRubyObject[]{ runtime.getClassFromPath("Timeout::Error"), re.getException().callMethod(context, "message"), re.getException().callMethod(context, "backtrace")}, Block.NULL_BLOCK); } }
private static IRubyObject raiseTimeoutErrorIfMatches(ThreadContext context, final IRubyObject timeout, final RaiseException ex, final IRubyObject id) { // check if it's the exception intended for us if ( ex.getException().getInternalVariable("__identifier__") == id ) { final RubyException rubyException = ex.getException(); return RubyKernel.raise( // throws context, context.runtime.getKernel(), new IRubyObject[] { getClassFrom(timeout, "Error"), // Timeout::Error rubyException.callMethod(context, "message"), rubyException.callMethod(context, "backtrace") }, Block.NULL_BLOCK); } return null; }
@Override @JRubyMethod(name = "==") public RubyBoolean op_equal(ThreadContext context, IRubyObject other) { if (this == other) return context.tru; boolean equal = context.runtime.getException().isInstance(other) && getMetaClass().getRealClass() == other.getMetaClass().getRealClass() && callMethod(context, "message").equals(other.callMethod(context, "message")) && callMethod(context, "backtrace").equals(other.callMethod(context, "backtrace")); return context.runtime.newBoolean(equal); }
private static IRubyObject raiseTimeoutErrorIfMatches(ThreadContext context, final IRubyObject timeout, final RaiseException ex, final IRubyObject id) { // check if it's the exception intended for us if ( ex.getException().getInternalVariable("__identifier__") == id ) { final RubyException rubyException = ex.getException(); return RubyKernel.raise( // throws context, context.runtime.getKernel(), new IRubyObject[] { getClassFrom(timeout, "Error"), // Timeout::Error rubyException.callMethod(context, "message"), rubyException.callMethod(context, "backtrace") }, Block.NULL_BLOCK); } return null; }
@Override @JRubyMethod(name = "==") public RubyBoolean op_equal(ThreadContext context, IRubyObject other) { if (this == other) return context.tru; boolean equal = context.runtime.getException().isInstance(other) && getMetaClass().getRealClass() == other.getMetaClass().getRealClass() && callMethod(context, "message").equals(other.callMethod(context, "message")) && callMethod(context, "backtrace").equals(other.callMethod(context, "backtrace")); return context.runtime.newBoolean(equal); }
@JRubyMethod(name = "==", compat = CompatVersion.RUBY1_9) @Override public IRubyObject op_equal(ThreadContext context, IRubyObject other) { if (this == other) return context.runtime.getTrue(); boolean equal = context.runtime.getException().isInstance(other) && callMethod(context, "message").equals(other.callMethod(context, "message")) && callMethod(context, "backtrace").equals(other.callMethod(context, "backtrace")); if (context.runtime.is2_0()) { equal = equal && getMetaClass().getRealClass() == other.getMetaClass().getRealClass(); } return context.runtime.newBoolean(equal); }
@JRubyMethod(name = "==", compat = CompatVersion.RUBY1_9) @Override public IRubyObject op_equal(ThreadContext context, IRubyObject other) { if (this == other) return context.runtime.getTrue(); boolean equal = context.runtime.getException().isInstance(other) && callMethod(context, "message").equals(other.callMethod(context, "message")) && callMethod(context, "backtrace").equals(other.callMethod(context, "backtrace")); if (context.runtime.is2_0()) { equal = equal && getMetaClass().getRealClass() == other.getMetaClass().getRealClass(); } return context.runtime.newBoolean(equal); }
protected static String printBacktraceJRuby(RubyException exception, boolean console) { final Ruby runtime = exception.getRuntime(); final ThreadContext context = runtime.getCurrentContext(); boolean color = console && runtime.getInstanceConfig().getBacktraceColor(); // exception line String message; try { message = exception.callMethod(context, "message").toString(); } catch (org.jruby.exceptions.Exception unused) { message = exception.message(context).toString(); } if (exception.getMetaClass() == runtime.getRuntimeError() && message.length() == 0) { message = "No current exception"; } String type = exception.getMetaClass().getName(); return printBacktraceJRuby(exception.getRuntime(), exception.getBacktraceElements(), type, message, color); }
protected static String printBacktraceJRuby(RubyException exception, boolean console) { final Ruby runtime = exception.getRuntime(); final ThreadContext context = runtime.getCurrentContext(); boolean color = console && runtime.getInstanceConfig().getBacktraceColor(); // exception line String message; try { message = exception.callMethod(context, "message").toString(); } catch (org.jruby.exceptions.Exception unused) { message = exception.message(context).toString(); } if (exception.getMetaClass() == runtime.getRuntimeError() && message.length() == 0) { message = "No current exception"; } String type = exception.getMetaClass().getName(); return printBacktraceJRuby(exception.getRuntime(), exception.getBacktraceElements(), type, message, color); }
/** * Print the Ruby exception's backtrace to the given PrintStream. This * version accepts a number of lines to skip and is primarily used * internally for exception printing where the first line is treated specially. * * @param errorStream the PrintStream to which backtrace should be printed */ public void printBacktrace(PrintStream errorStream, int skip) { IRubyObject backtrace = callMethod(getRuntime().getCurrentContext(), "backtrace"); if (!backtrace.isNil() && backtrace instanceof RubyArray) { IRubyObject[] elements = backtrace.convertToArray().toJavaArray(); for (int i = skip; i < elements.length; i++) { IRubyObject stackTraceLine = elements[i]; if (stackTraceLine instanceof RubyString) { printStackTraceLine(errorStream, stackTraceLine); } } } }
/** * Print the Ruby exception's backtrace to the given PrintStream. This * version accepts a number of lines to skip and is primarily used * internally for exception printing where the first line is treated specially. * * @param errorStream the PrintStream to which backtrace should be printed */ public void printBacktrace(PrintStream errorStream, int skip) { IRubyObject backtrace = callMethod(getRuntime().getCurrentContext(), "backtrace"); if (!backtrace.isNil() && backtrace instanceof RubyArray) { IRubyObject[] elements = backtrace.convertToArray().toJavaArray(); for (int i = skip; i < elements.length; i++) { IRubyObject stackTraceLine = elements[i]; if (stackTraceLine instanceof RubyString) { printStackTraceLine(errorStream, stackTraceLine); } } } }
private static int handleRaiseException(RaiseException rj) { RubyException raisedException = rj.getException(); Ruby runtime = raisedException.getRuntime(); if (runtime.getSystemExit().isInstance(raisedException)) { IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "status"); if (status != null && !status.isNil()) { return RubyNumeric.fix2int(status); } else { return 0; } } else { runtime.getErrorStream().print(runtime.getInstanceConfig().getTraceType().printBacktrace(raisedException, runtime.getPosix().isatty(FileDescriptor.err))); return 1; } }
private static int handleRaiseException(RaiseException rj) { RubyException raisedException = rj.getException(); Ruby runtime = raisedException.getRuntime(); if (runtime.getSystemExit().isInstance(raisedException)) { IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "status"); if (status != null && !status.isNil()) { return RubyNumeric.fix2int(status); } else { return 0; } } else { runtime.getErrorStream().print(runtime.getInstanceConfig().getTraceType().printBacktrace(raisedException, runtime.getPosix().isatty(FileDescriptor.err))); return 1; } }