private static void printExceptionSummary(Ruby runtime, RubyException rEx) { RubyStackTraceElement[] elements = rEx.getBacktraceElements(); RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false); String msg = String.format("Exception `%s' at %s:%s - %s\n", rEx.getMetaClass(), firstElement.getFileName(), firstElement.getLineNumber(), TypeConverter.convertToType(rEx, runtime.getString(), "to_s")); runtime.getErrorStream().print(msg); }
private static void printExceptionSummary(Ruby runtime, RubyException rEx) { RubyStackTraceElement[] elements = rEx.getBacktraceElements(); RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false); String msg = String.format("Exception `%s' at %s:%s - %s\n", rEx.getMetaClass(), firstElement.getFileName(), firstElement.getLineNumber(), TypeConverter.convertToType(rEx, runtime.getString(), "to_s")); runtime.getErrorStream().print(msg); }
@Override public String getMessage() { if (providedMessage == null) { providedMessage = '(' + exception.getMetaClass().getBaseName() + ") " + exception.message(exception.getRuntime().getCurrentContext()).asJavaString(); } return providedMessage; }
@Override public String getMessage() { if (providedMessage == null) { providedMessage = "(" + exception.getMetaClass().getBaseName() + ") " + exception.message(exception.getRuntime().getCurrentContext()).asJavaString(); } return providedMessage; }
@Override public String getMessage() { if (providedMessage == null) { providedMessage = "(" + exception.getMetaClass().getBaseName() + ") " + exception.message(exception.getRuntime().getCurrentContext()).asJavaString(); } return providedMessage; }
@Override public String getMessage() { if (providedMessage == null) { providedMessage = '(' + exception.getMetaClass().getBaseName() + ") " + exception.message(exception.getRuntime().getCurrentContext()).asJavaString(); } return providedMessage; }
private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) { RubyStackTraceElement[] elements = rEx.getBacktraceElements(); RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false); String msg = String.format("Exception `%s' at %s:%s - %s\n", rEx.getMetaClass(), firstElement.getFileName(), firstElement.getLineNumber(), runtime.is1_9() ? TypeConverter.convertToType(rEx, runtime.getString(), "to_s") : rEx.convertToString().toString()); runtime.getErrorStream().print(msg); }
private static void printExceptionSummary(ThreadContext context, Ruby runtime, RubyException rEx) { RubyStackTraceElement[] elements = rEx.getBacktraceElements(); RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] : new RubyStackTraceElement("", "", "(empty)", 0, false); String msg = String.format("Exception `%s' at %s:%s - %s\n", rEx.getMetaClass(), firstElement.getFileName(), firstElement.getLineNumber(), runtime.is1_9() ? TypeConverter.convertToType(rEx, runtime.getString(), "to_s") : rEx.convertToString().toString()); runtime.getErrorStream().print(msg); }
@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); }
@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(visibility = PRIVATE) public static IRubyObject path2class(ThreadContext context, IRubyObject self, IRubyObject path) { try { return context.runtime.getClassFromPath(path.asJavaString()); } catch (RaiseException re) { if (re.getException().getMetaClass() == context.runtime.getNameError()) { throw context.runtime.newArgumentError("undefined class/module " + path); } throw re; } } }
@JRubyMethod(visibility = PRIVATE) public static IRubyObject path2class(ThreadContext context, IRubyObject self, IRubyObject path) { try { return context.runtime.getClassFromPath(path.asJavaString()); } catch (RaiseException re) { if (re.getException().getMetaClass() == context.runtime.getNameError()) { throw context.runtime.newArgumentError("undefined class/module " + path); } throw re; } } }
@JRubyMethod(name = "to_s") public IRubyObject to_s(ThreadContext context) { final IRubyObject msg = getMessage(); if ( ! msg.isNil() ) return msg.asString(); return context.runtime.newString(getMetaClass().getRealClass().getName()); }
@JRubyMethod(name = "to_s") public IRubyObject to_s(ThreadContext context) { final IRubyObject msg = getMessage(); if ( ! msg.isNil() ) return msg.asString(); return context.runtime.newString(getMetaClass().getRealClass().getName()); }
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_8) public IRubyObject to_s(ThreadContext context) { if (message.isNil()) { return context.runtime.newString(getMetaClass().getRealClass().getName()); } message.setTaint(isTaint()); return message; }
@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); }
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_8) public IRubyObject to_s(ThreadContext context) { if (message.isNil()) { return context.runtime.newString(getMetaClass().getRealClass().getName()); } message.setTaint(isTaint()); return message; }
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_9) public IRubyObject to_s19(ThreadContext context) { if (message.isNil()) { return context.runtime.newString(getMetaClass().getRealClass().getName()); } message.setTaint(isTaint()); return message.asString(); }
@JRubyMethod(name = "to_s", compat = CompatVersion.RUBY1_9) public IRubyObject to_s19(ThreadContext context) { if (message.isNil()) { return context.runtime.newString(getMetaClass().getRealClass().getName()); } message.setTaint(isTaint()); return message.asString(); }