Example #1
0
  public void exceptionRaised(RaiseException exception) {
    assert isCurrent();

    RubyException rubyException = exception.getException();
    Ruby runtime = rubyException.getRuntime();
    if (runtime.getSystemExit().isInstance(rubyException)) {
      runtime
          .getThreadService()
          .getMainThread()
          .raise(new IRubyObject[] {rubyException}, Block.NULL_BLOCK);
    } else if (abortOnException(runtime)) {
      RubyException systemExit;

      if (!runtime.is1_9()) {
        runtime.printError(rubyException);

        systemExit = RubySystemExit.newInstance(runtime, 1);
        systemExit.message = rubyException.message;
        systemExit.set_backtrace(rubyException.backtrace());
      } else {
        systemExit = rubyException;
      }

      runtime
          .getThreadService()
          .getMainThread()
          .raise(new IRubyObject[] {systemExit}, Block.NULL_BLOCK);
      return;
    } else if (runtime.getDebug().isTrue()) {
      runtime.printError(exception.getException());
    }
    exitingException = exception;
  }