Package org.jruby

Examples of org.jruby.RubyException


    private static void dumpThread(Ruby ruby, RubyThread th, Gather gather, PrintWriter pw) {
        pw.println("Thread: " + th.getNativeThread().getName());
        pw.println("Stack:");
        ThreadContext tc = th.getContext();
        if (tc != null) {
            RubyException exc = new RubyException(ruby, ruby.getRuntimeError(), "thread dump");
            exc.setBacktraceData(gather.getBacktraceData(tc, th.getNativeThread().getStackTrace(), true));
            pw.println(Format.MRI.printBacktrace(exc, false));
        } else {
            pw.println("    [no longer alive]");
        }
        pw.println();
View Full Code Here


        if (posix.isNative()) {
            try {
                RubyFile.unlink(context, this);
            } catch (RaiseException re) {
                RubyException excp = re.getException();
                if (!(excp instanceof RubySystemCallError)) throw re;

                int errno = (int)((RubySystemCallError)excp).errno().convertToInteger().getLongValue();
                if (errno != Errno.ENOENT.intValue() &&
                        errno != Errno.EACCES.intValue()) {
View Full Code Here

            // package name. (and seriously, folks, look into best practices...)
            IRubyObject previousErrorInfo = Helpers.getErrorInfo(runtime);
            try {
                return getProxyClass(runtime, runtime.getJavaSupport().loadJavaClassQuiet(fullName));
            } catch (RaiseException re) { /* expected */
                RubyException rubyEx = re.getException();
                if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
                    Helpers.setErrorInfo(runtime, previousErrorInfo);
                }
            } catch (Exception e) { /* expected */ }

            // Haven't found a class, continue on as though it were a package
View Full Code Here

        if (Character.isLowerCase(name.charAt(0))) {
            // this covers primitives and (unlikely) lower-case class names
            try {
                return getProxyClass(runtime, runtime.getJavaSupport().loadJavaClassQuiet(name));
            } catch (RaiseException re) { /* not primitive or lc class */
                RubyException rubyEx = re.getException();
                if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
                    Helpers.setErrorInfo(runtime, runtime.getNil());
                }
            } catch (Exception e) { /* not primitive or lc class */ }

            // TODO: check for Java reserved names and raise exception if encountered
View Full Code Here

        } catch (IOException e) {
            RaiseException re = RubyZlib.newGzipFileError(runtime, "not in gzip format");

            byte[] input = io.getAvailIn();
            if (input != null && input.length > 0) {
                RubyException rubye = re.getException();
                rubye.setInstanceVariable("@input",
                        RubyString.newString(runtime, new ByteList(input, 0, input.length)));
            }

            throw re;
        }
View Full Code Here

        return newGzipFileError(runtime, "LengthError", message);
    }

    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 new RaiseException(excn, true);
    }
View Full Code Here

    }
   
    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;
View Full Code Here

    try {
      return JRubyScriptUtils.createJRubyObject(
          scriptSource.getScriptAsString(), actualInterfaces, this.beanClassLoader);
    }
    catch (RaiseException ex) {
      RubyException rubyEx = ex.getException();
      String msg = (rubyEx != null && rubyEx.message != null) ?
          rubyEx.message.toString() : "Unexpected JRuby error";
      throw new ScriptCompilationException(scriptSource, msg, ex);
    }
    catch (JumpException ex) {
View Full Code Here

    try {
      return JRubyScriptUtils.createJRubyObject(
          scriptSource.getScriptAsString(), actualInterfaces, this.beanClassLoader);
    }
    catch (RaiseException ex) {
      RubyException rubyEx = ex.getException();
      String msg = (rubyEx != null && rubyEx.message != null) ?
          rubyEx.message.toString() : "Unexpected JRuby error";
      throw new ScriptCompilationException(scriptSource, msg, ex);
    }
    catch (JumpException ex) {
View Full Code Here

    public JRubyExecutionException(RaiseException ex) {
      super(buildMessage(ex), ex);
    }

    private static String buildMessage(RaiseException ex) {
      RubyException rubyEx = ex.getException();
      return (rubyEx != null && rubyEx.message != null) ? rubyEx.message.toString() : "Unexpected JRuby error";
    }
View Full Code Here

TOP

Related Classes of org.jruby.RubyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.