/** * @param exceptionClass * @param message * @return */ public RaiseException newRaiseException(RubyClass exceptionClass, String message) { return new RaiseException(this, exceptionClass, message, true); }
/** * @param exceptionClass * @param message * @return */ public RaiseException newRaiseException(RubyClass exceptionClass, String message) { return new RaiseException(this, exceptionClass, message, true); }
@Deprecated public static RaiseException from(RubyException exception, IRubyObject backtrace) { // FIXME: This form currently creates a new exception since it's providing a backtrace return new RaiseException(exception, backtrace); }
@Deprecated public static RaiseException from(RubyException exception, IRubyObject backtrace) { // FIXME: This form currently creates a new exception since it's providing a backtrace return new RaiseException(exception, backtrace); }
public synchronized void checkShutdown(ThreadContext context) { if (entries == null) { throw new RaiseException(context.runtime, context.runtime.getThreadError(), "queue shut down", false); } }
public synchronized void checkShutdown(ThreadContext context) { if (entries == null) { throw new RaiseException(context.runtime, context.runtime.getThreadError(), "queue shut down", false); } }
@Deprecated public static RuntimeException sockerr(Ruby runtime, String msg) { return new RaiseException(runtime, runtime.getClass("SocketError"), msg, true); }
@Deprecated public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) { org.jruby.NativeException nativeException = new org.jruby.NativeException(runtime, runtime.getNativeException(), cause); return new RaiseException(cause, nativeException); }
@Deprecated public static RaiseException createNativeRaiseException(Ruby runtime, Throwable cause, Member target) { org.jruby.NativeException nativeException = new org.jruby.NativeException(runtime, runtime.getNativeException(), cause); return new RaiseException(cause, nativeException); }
static RaiseException newZlibError(Ruby runtime, String klass, String message) { RubyClass errorClass = runtime.getModule("Zlib").getClass(klass); return new RaiseException(RubyException.newException(runtime, errorClass, message), true); }
static MemoryPointer allocate(Ruby runtime, int typeSize, int count, boolean clear) { final int total = typeSize * count; MemoryIO io = Factory.getInstance().allocateDirectMemory(runtime, total > 0 ? total : 1, clear); if (io == null) { throw new RaiseException(runtime, runtime.getNoMemoryError(), String.format("Failed to allocate %d objects of %d bytes", count, typeSize), true); } return new MemoryPointer(runtime, runtime.getFFI().memptrClass, io, total, typeSize); }
public RaiseException newNameError(String message, String name, Throwable origException, boolean printWhenVerbose) { if (origException != null) { if (printWhenVerbose && isVerbose()) { LOG.error(origException.getMessage(), origException); } else if (isDebug()) { LOG.debug(origException.getMessage(), origException); } } return new RaiseException(new RubyNameError( this, getNameError(), message, name), false); }
public static void sysFail(Ruby runtime, String message, int n) { IRubyObject arg = (message != null) ? runtime.newString(message) : runtime.getNil(); RubyClass instance = runtime.getErrno(n); if(instance == null) { instance = runtime.getSystemCallError(); throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg, runtime.newFixnum(n)}, Block.NULL_BLOCK))); } else { throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg}, Block.NULL_BLOCK))); } }
public static void sysFail(Ruby runtime, String message, int n) { IRubyObject arg = (message != null) ? runtime.newString(message) : runtime.getNil(); RubyClass instance = runtime.getErrno(n); if(instance == null) { instance = runtime.getSystemCallError(); throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg, runtime.newFixnum(n)}, Block.NULL_BLOCK))); } else { throw new RaiseException((RubyException)(instance.newInstance(runtime.getCurrentContext(), new IRubyObject[]{arg}, Block.NULL_BLOCK))); } }
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 RaiseException newRefError(String message) { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); RubyException exception = (RubyException)runtime.getClass("WeakRef").getClass("RefError").newInstance(context, new IRubyObject[] {runtime.newString(message)}, Block.NULL_BLOCK); RaiseException re = new RaiseException(exception); return re; } }
private RaiseException newRefError(String message) { Ruby runtime = getRuntime(); ThreadContext context = runtime.getCurrentContext(); RubyException exception = (RubyException)runtime.getClass("WeakRef").getClass("RefError").newInstance(context, new IRubyObject[] {runtime.newString(message)}, Block.NULL_BLOCK); RaiseException re = new RaiseException(exception); return re; } }
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); if (runtime.is1_9()) { // TODO: not yet supported. rewrite GzipReader/Writer with Inflate/Deflate? excn.setInstanceVariable("@input", runtime.getNil()); } return new RaiseException(excn, true); }
@JRubyMethod(name = "unscan") public IRubyObject unscan() { check(); Ruby runtime = getRuntime(); if (!isMatched()) { RubyClass errorClass = runtime.getClass("StringScanner").getClass("Error"); throw new RaiseException(RubyException.newException( runtime, errorClass, "unscan failed: previous match had failed")); } pos = lastPos; clearMatched(); return this; }