org.jruby.Ruby.getNameError()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(128)

本文整理了Java中org.jruby.Ruby.getNameError方法的一些代码示例,展示了Ruby.getNameError的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getNameError方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getNameError

Ruby.getNameError介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

@Deprecated
public RaiseException newNameErrorObject(String message, IRubyObject name) {
  RubyException error = new RubyNameError(this, getNameError(), message, name);
  return error.toThrowable();
}

代码示例来源:origin: org.jruby/jruby-core

@Deprecated
public RaiseException newNameErrorObject(String message, IRubyObject name) {
  RubyException error = new RubyNameError(this, getNameError(), message, name);
  return error.toThrowable();
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public RaiseException newNameErrorObject(String message, IRubyObject name) {
  RubyException error = new RubyNameError(this, getNameError(), message, name);
  return new RaiseException(error, false);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public RaiseException newNameErrorObject(String message, IRubyObject name) {
  RubyException error = new RubyNameError(this, getNameError(), message, name);
  return new RaiseException(error, false);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

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);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

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);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * 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();
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * 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();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

protected static IRubyObject methodMissingDirect(ThreadContext context, IRubyObject recv, RubySymbol symbol, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args, 1)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod(visibility = PRIVATE)
  public static IRubyObject path2class(ThreadContext context, IRubyObject self, IRubyObject path) {
    try {
      return context.runtime.getClassFromPath(path.asJavaString());
    } catch (RaiseException re) {
      if (re.getException().getMetaClass() == context.runtime.getNameError()) {
        throw context.runtime.newArgumentError("undefined class/module " + path);
      }
      throw re;
    }
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@JRubyMethod(visibility = PRIVATE)
  public static IRubyObject path2class(ThreadContext context, IRubyObject self, IRubyObject path) {
    try {
      return context.runtime.getClassFromPath(path.asJavaString());
    } catch (RaiseException re) {
      if (re.getException().getMetaClass() == context.runtime.getNameError()) {
        throw context.runtime.newArgumentError("undefined class/module " + path);
      }
      throw re;
    }
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

protected static IRubyObject methodMissingDirect(ThreadContext context, IRubyObject recv, RubySymbol symbol, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args, 1)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Construct a NameError with the given pre-formatted message, name, and optional original exception.
 *
 * If the original exception is given, and either we are in verbose mode with printWhenVerbose set to true
 * or we are in debug mode.
 *
 * @param message the pre-formatted message for the NameError
 * @param name the name that failed
 * @param exception the original exception, or null
 * @param printWhenVerbose whether to log this exception when verbose mode is enabled
 * @return a new NameError
 */
public RaiseException newNameError(String message, String name, Throwable exception, boolean printWhenVerbose) {
  if (exception != null) {
    if (printWhenVerbose && isVerbose()) {
      LOG.error(exception);
    } else if (isDebug()) {
      LOG.debug(exception);
    }
  }
  return new RubyNameError(this, getNameError(), message, name).toThrowable();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  RubySymbol symbol = runtime.newSymbol(name);
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

public static IRubyObject methodMissing(ThreadContext context, IRubyObject recv, String name, Visibility lastVis, CallType lastCallType, IRubyObject[] args, Block block) {
  Ruby runtime = context.runtime;
  RubySymbol symbol = runtime.newSymbol(name);
  // create a lightweight thunk
  IRubyObject msg = new RubyNameError.RubyNameErrorMessage(runtime,
                               recv,
                               symbol,
                               lastVis,
                               lastCallType);
  final IRubyObject[]exArgs;
  final RubyClass exc;
  if (lastCallType != CallType.VARIABLE) {
    exc = runtime.getNoMethodError();
    exArgs = new IRubyObject[]{msg, symbol, RubyArray.newArrayNoCopy(runtime, args)};
  } else {
    exc = runtime.getNameError();
    exArgs = new IRubyObject[]{msg, symbol};
  }
  throw new RaiseException((RubyException)exc.newInstance(context, exArgs, Block.NULL_BLOCK));
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Construct a NameError with the given pre-formatted message, name, and optional original exception.
 *
 * If the original exception is given, and either we are in verbose mode with printWhenVerbose set to true
 * or we are in debug mode.
 *
 * @param message the pre-formatted message for the NameError
 * @param name the name that failed
 * @param exception the original exception, or null
 * @param printWhenVerbose whether to log this exception when verbose mode is enabled
 * @return a new NameError
 */
public RaiseException newNameError(String message, String name, Throwable exception, boolean printWhenVerbose) {
  if (exception != null) {
    if (printWhenVerbose && isVerbose()) {
      LOG.error(exception);
    } else if (isDebug()) {
      LOG.debug(exception);
    }
  }
  return new RubyNameError(this, getNameError(), message, name).toThrowable();
}

相关文章

Ruby类方法