@Override public void run() { try { result[0] = ruby.get().evalScriptlet(code).toString(); } catch (RaiseException re) { result[0] = ruby.get().getInstanceConfig().getTraceType().printBacktrace(re.getException(), false); } catch (Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); result[0] = sw.toString(); } } };
@Override public void run() { try { result[0] = ruby.get().evalScriptlet(code).toString(); } catch (RaiseException re) { result[0] = ruby.get().getInstanceConfig().getTraceType().printBacktrace(re.getException(), false); } catch (Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); result[0] = sw.toString(); } } };
@Override public void run() { // IRubyObject oldExc = ruby.get().getGlobalVariables().get("$!"); // Save $! try { result[0] = ruby.get().evalScriptlet(code).toString(); } catch (RaiseException re) { result[0] = ruby.get().getInstanceConfig().getTraceType().printBacktrace(re.getException(), false); // ruby.get().getGlobalVariables().set("$!", oldExc); // Restore $! } catch (Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); result[0] = sw.toString(); } } };
@Override public void run() { // IRubyObject oldExc = ruby.get().getGlobalVariables().get("$!"); // Save $! try { result[0] = ruby.get().evalScriptlet(code).toString(); } catch (RaiseException re) { result[0] = ruby.get().getInstanceConfig().getTraceType().printBacktrace(re.getException(), false); // ruby.get().getGlobalVariables().set("$!", oldExc); // Restore $! } catch (Throwable t) { StringWriter sw = new StringWriter(); t.printStackTrace(new PrintWriter(sw)); result[0] = sw.toString(); } } };
/** Prints an error with backtrace to the error stream. * * MRI: eval.c - error_print() * */ public void printError(RubyException excp) { if (excp == null || excp.isNil()) { return; } PrintStream errorStream = getErrorStream(); String backtrace = config.getTraceType().printBacktrace(excp, errorStream == System.err && getPosix().isatty(FileDescriptor.err)); try { errorStream.print(backtrace); } catch (Exception e) { System.err.print(backtrace); } }
/** Prints an error with backtrace to the error stream. * * MRI: eval.c - error_print() * */ public void printError(RubyException excp) { if (excp == null || excp.isNil()) { return; } PrintStream errorStream = getErrorStream(); errorStream.print(config.getTraceType().printBacktrace(excp, errorStream == System.err && getPosix().isatty(FileDescriptor.err))); }
/** Prints an error with backtrace to the error stream. * * MRI: eval.c - error_print() * */ public void printError(RubyException excp) { if (excp == null || excp.isNil()) { return; } PrintStream errorStream = getErrorStream(); errorStream.print(config.getTraceType().printBacktrace(excp, errorStream == System.err && getPosix().isatty(FileDescriptor.err))); }
/** Prints an error with backtrace to the error stream. * * MRI: eval.c - error_print() * */ public void printError(RubyException excp) { if (excp == null || excp.isNil()) { return; } PrintStream errorStream = getErrorStream(); String backtrace = config.getTraceType().printBacktrace(excp, errorStream == System.err && getPosix().isatty(FileDescriptor.err)); try { errorStream.print(backtrace); } catch (Exception e) { System.err.print(backtrace); } }
protected void warnCircularRequire(String requireName) { runtime.getWarnings().warn("loading in progress, circular require considered harmful - " + requireName); // it's a hack for c:rb_backtrace impl. // We should introduce new method to Ruby.TraceType when rb_backtrace is widely used not only for this purpose. RaiseException ex = new RaiseException(runtime, runtime.getRuntimeError(), null, false); String trace = runtime.getInstanceConfig().getTraceType().printBacktrace(ex.getException(), runtime.getPosix().isatty(FileDescriptor.err)); // rb_backtrace dumps to stderr directly. System.err.print(trace.replaceFirst("[^\n]*\n", "")); }
protected void warnCircularRequire(String requireName) { runtime.getWarnings().warn("loading in progress, circular require considered harmful - " + requireName); // it's a hack for c:rb_backtrace impl. // We should introduce new method to Ruby.TraceType when rb_backtrace is widely used not only for this purpose. RaiseException ex = new RaiseException(runtime, runtime.getRuntimeError(), null, false); String trace = runtime.getInstanceConfig().getTraceType().printBacktrace(ex.getException(), runtime.getPosix().isatty(FileDescriptor.err)); // rb_backtrace dumps to stderr directly. System.err.print(trace.replaceFirst("[^\n]*\n", "")); }
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; } }
/** * This is only used from the main(String[]) path, in which case the err for this * run should be System.err. In order to avoid the Ruby err being closed and unable * to write, we use System.err unconditionally. * * @param ex * @return */ protected static int handleRaiseException(final RaiseException ex) { RubyException raisedException = ex.getException(); final 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); } return 0; } else if ( runtime.getSignalException().isInstance(raisedException) ) { IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "signo"); if (status != null && ! status.isNil()) { return RubyNumeric.fix2int(status) + 128; } return 0; } System.err.print(runtime.getInstanceConfig().getTraceType().printBacktrace(raisedException, runtime.getPosix().isatty(FileDescriptor.err))); return 1; }
/** * This is only used from the main(String[]) path, in which case the err for this * run should be System.err. In order to avoid the Ruby err being closed and unable * to write, we use System.err unconditionally. * * @param ex * @return */ protected static int handleRaiseException(final RaiseException ex) { RubyException raisedException = ex.getException(); final 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); } return 0; } else if ( runtime.getSignalException().isInstance(raisedException) ) { IRubyObject status = raisedException.callMethod(runtime.getCurrentContext(), "signo"); if (status != null && ! status.isNil()) { return RubyNumeric.fix2int(status) + 128; } return 0; } System.err.print(runtime.getInstanceConfig().getTraceType().printBacktrace(raisedException, runtime.getPosix().isatty(FileDescriptor.err))); return 1; }