public static RaiseException from(Ruby runtime, RubyClass excptnClass, String msg, IRubyObject backtrace) { return RubyException.newException(runtime, excptnClass, msg).toThrowable(); }
public static RaiseException from(Ruby runtime, RubyClass excptnClass, String msg) { return RubyException.newException(runtime, excptnClass, msg).toThrowable(); }
public static RaiseException from(Ruby runtime, RubyClass excptnClass, String msg, IRubyObject backtrace) { return RubyException.newException(runtime, excptnClass, msg).toThrowable(); }
public static RaiseException from(Ruby runtime, RubyClass excptnClass, String msg) { return RubyException.newException(runtime, excptnClass, msg).toThrowable(); }
private IRubyObject returnValue(IRubyObject value, final boolean silent) { // if it's the NEVER object, raise StopIteration if (value == NEVER) { doneObject = value; if ( silent ) return null; throw runtime.newStopIteration(stopValue, "iteration reached an end"); } // if it's an exception, raise it if (value instanceof RubyException) { doneObject = value; if ( silent ) return null; throw ((RubyException) value).toThrowable(); } // otherwise, just return it return value; }
/** * Coerce this Ruby exception to the requested Java type, if possible. * * If the requested type is a supertype of RaiseException, the attached throwable will be returned. * * Otherwise, it will fall back on RubyBasicObject toJava logic. * * @param target the target type to which this object should be converted * @return the converted result */ @Override public <T> T toJava(Class<T> target) { if (target != Object.class && target.isAssignableFrom(RaiseException.class)) { return target.cast(toThrowable()); } return super.toJava(target); }
private IRubyObject returnValue(IRubyObject value, final boolean silent) { // if it's the NEVER object, raise StopIteration if (value == NEVER) { doneObject = value; if ( silent ) return null; throw runtime.newStopIteration(stopValue, "iteration reached an end"); } // if it's an exception, raise it if (value instanceof RubyException) { doneObject = value; if ( silent ) return null; throw ((RubyException) value).toThrowable(); } // otherwise, just return it return value; }
/** * Coerce this Ruby exception to the requested Java type, if possible. * * If the requested type is a supertype of RaiseException, the attached throwable will be returned. * * Otherwise, it will fall back on RubyBasicObject toJava logic. * * @param target the target type to which this object should be converted * @return the converted result */ @Override public <T> T toJava(Class<T> target) { if (target != Object.class && target.isAssignableFrom(RaiseException.class)) { return target.cast(toThrowable()); } return super.toJava(target); }
@Deprecated public RaiseException newNameErrorObject(String message, IRubyObject name) { RubyException error = new RubyNameError(this, getNameError(), message, name); return error.toThrowable(); }
@Deprecated public RaiseException newNameErrorObject(String message, IRubyObject name) { RubyException error = new RubyNameError(this, getNameError(), message, name); return error.toThrowable(); }
/** * Construct a NameError that formats its message with an sprintf format string. * * The arguments given to sprintf are as follows: * * 0: the name that failed * 1: the receiver object that failed * 2: a ":" character for non-singleton recv, blank otherwise * 3: the name of the a non-singleton recv's class, blank if recv is a singleton * * Passing a string with no format characters will warn in verbose mode and error in debug mode. * * See jruby/jruby#3934. * * @param message an sprintf format string for the message * @param recv the receiver object * @param name the name that failed * @param privateCall whether the failure was due to method visibility * @return a new NameError */ public RaiseException newNameError(String message, IRubyObject recv, IRubyObject name, boolean privateCall) { IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, name); RubyException err = RubyNameError.newNameError(getNameError(), msg, name, privateCall); return err.toThrowable(); }
/** * Construct a NameError that formats its message with an sprintf format string. * * The arguments given to sprintf are as follows: * * 0: the name that failed * 1: the receiver object that failed * 2: a ":" character for non-singleton recv, blank otherwise * 3: the name of the a non-singleton recv's class, blank if recv is a singleton * * Passing a string with no format characters will warn in verbose mode and error in debug mode. * * See jruby/jruby#3934. * * @param message an sprintf format string for the message * @param recv the receiver object * @param name the name that failed * @param privateCall whether the failure was due to method visibility * @return a new NameError */ public RaiseException newNameError(String message, IRubyObject recv, IRubyObject name, boolean privateCall) { IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, name); RubyException err = RubyNameError.newNameError(getNameError(), msg, name, privateCall); return err.toThrowable(); }
/** * Construct a NoMethodError that formats its message with an sprintf format string. * * This works like {@link #newNameError(String, IRubyObject, IRubyObject)} but accepts * a java.lang.String for name and a RubyArray of the original call arguments. * * @see Ruby#newNameError(String, IRubyObject, IRubyObject) * * @return a new NoMethodError */ public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) { RubySymbol nameStr = newSymbol(name); IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr); RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args, privateCall); return err.toThrowable(); }
/** * Generate a StopIteration exception. This differs from the normal logic * by avoiding the generation of a backtrace. StopIteration is used by * Enumerator to end an external iteration, and so generating a full * backtrace is usually unreasonable overhead. The flag * -Xstop_iteration.backtrace=true or the property * jruby.stop_iteration.backtrace=true forces all StopIteration exceptions * to generate a backtrace. * * @param message the message for the exception */ public RaiseException newStopIteration(IRubyObject result, String message) { final ThreadContext context = getCurrentContext(); if (message == null) message = STOPIERATION_BACKTRACE_MESSAGE; RubyException ex = RubyStopIteration.newInstance(context, result, message); if (!RubyInstanceConfig.STOPITERATION_BACKTRACE) { ex.forceBacktrace(disabledBacktrace()); } return ex.toThrowable(); }
/** * Construct a NoMethodError that formats its message with an sprintf format string. * * This works like {@link #newNameError(String, IRubyObject, IRubyObject)} but accepts * a java.lang.String for name and a RubyArray of the original call arguments. * * @see Ruby#newNameError(String, IRubyObject, IRubyObject) * * @return a new NoMethodError */ public RaiseException newNoMethodError(String message, IRubyObject recv, String name, RubyArray args, boolean privateCall) { RubySymbol nameStr = newSymbol(name); IRubyObject msg = new RubyNameError.RubyNameErrorMessage(this, message, recv, nameStr); RubyException err = RubyNoMethodError.newNoMethodError(getNoMethodError(), msg, nameStr, args, privateCall); return err.toThrowable(); }
/** * Generate a StopIteration exception. This differs from the normal logic * by avoiding the generation of a backtrace. StopIteration is used by * Enumerator to end an external iteration, and so generating a full * backtrace is usually unreasonable overhead. The flag * -Xstop_iteration.backtrace=true or the property * jruby.stop_iteration.backtrace=true forces all StopIteration exceptions * to generate a backtrace. * * @param message the message for the exception */ public RaiseException newStopIteration(IRubyObject result, String message) { final ThreadContext context = getCurrentContext(); if (message == null) message = STOPIERATION_BACKTRACE_MESSAGE; RubyException ex = RubyStopIteration.newInstance(context, result, message); if (!RubyInstanceConfig.STOPITERATION_BACKTRACE) { ex.forceBacktrace(disabledBacktrace()); } return ex.toThrowable(); }
static RaiseException newGzipFileError(Ruby runtime, String klass, String message) { RubyClass errorClass = runtime.getModule("Zlib").getClass("GzipFile").getClass(klass); RubyException excn = RubyException.newException(runtime, errorClass, message); // TODO: not yet supported. rewrite GzipReader/Writer with Inflate/Deflate? excn.setInstanceVariable("@input", runtime.getNil()); return excn.toThrowable(); }
static RaiseException newGzipFileError(Ruby runtime, String klass, String message) { RubyClass errorClass = runtime.getModule("Zlib").getClass("GzipFile").getClass(klass); RubyException excn = RubyException.newException(runtime, errorClass, message); // TODO: not yet supported. rewrite GzipReader/Writer with Inflate/Deflate? excn.setInstanceVariable("@input", runtime.getNil()); return excn.toThrowable(); }
} else { raise = ((RubyException) lastException).toThrowable(); raise = ((RubyException) runtime.getRuntimeError().newInstance(context, args, block)).toThrowable(); } else { raise = convertToException(context, args[0], null).toThrowable(); raise = convertToException(context, args[0], args[1]).toThrowable(); break; default: RubyException exception = convertToException(context, args[0], args[1]); exception.forceBacktrace(args[2]); raise = exception.toThrowable(); break;
throw runtime.newErrnoFromErrno(posix.errno, pathv); } else { throw ((RubyException)err).toThrowable();