Package org.jruby

Examples of org.jruby.RubyException


            // fail 99.999% of the time). fortunately, we'll only do this once per
            // package name. (and seriously, folks, look into best practices...)
            try {
                return getProxyClass(runtime, JavaClass.forNameQuiet(runtime, fullName));
            } catch (RaiseException re) { /* expected */
                RubyException rubyEx = re.getException();
                if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
                    RuntimeHelpers.setErrorInfo(runtime, runtime.getNil());
                }
            } 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, JavaClass.forNameQuiet(runtime, name));
            } catch (RaiseException re) { /* not primitive or lc class */
                RubyException rubyEx = re.getException();
                if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
                    RuntimeHelpers.setErrorInfo(runtime, runtime.getNil());
                }
            } catch (Exception e) { /* not primitive or lc class */ }

            // TODO: check for Java reserved names and raise exception if encountered

            final RubyModule packageModule = getJavaPackageModule(runtime, name);
            // TODO: decompose getJavaPackageModule so we don't parse fullName
            if (packageModule == null) {
                return null;
            }
            RubyModule javaModule = runtime.getJavaSupport().getJavaModule();
            if (javaModule.getMetaClass().isMethodBound(name, false)) {
                return packageModule;
            }

            memoizePackageOrClass(javaModule, name, packageModule);
           
            return packageModule;
        } else {
            RubyModule javaModule = null;
            try {
                javaModule = getProxyClass(runtime, JavaClass.forNameQuiet(runtime, name));
            } catch (RaiseException re) { /* not a class */
                RubyException rubyEx = re.getException();
                if (rubyEx.kind_of_p(context, runtime.getStandardError()).isTrue()) {
                    RuntimeHelpers.setErrorInfo(runtime, runtime.getNil());
                }
            } catch (Exception e) { /* not a class */ }

            // upper-case package name
View Full Code Here

    }
   
    private RaiseException newRefError(String message) {
        Ruby runtime = getRuntime();
        ThreadContext context = runtime.getCurrentContext();
        RubyException exception =
                (RubyException)runtime.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

    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

    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

    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(
          "Could not compile JRuby script [" + scriptSource + "]: " + msg, 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

        GlobalVariables oldGlobals = runtime.getGlobalVariables();
        try {
            setGlobalVariables(ctx);
            return rubyToJava(runtime.eval(node));
        } catch (RaiseException exp) {
            RubyException rexp = exp.getException();
            throw new ScriptException(rexp.toString());
        } catch (Exception exp) {
            throw new ScriptException(exp);
        } finally {
            if (oldGlobals != null) {
                //setGlobalVariables(oldGlobals);
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.