jnr.constants.platform.Errno.name()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(132)

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

Errno.name介绍

暂无

代码示例

代码示例来源:origin: jenkinsci/jenkins

private org.jruby.ext.posix.POSIX.ERRORS convert(Errno error) {
    try {
      return org.jruby.ext.posix.POSIX.ERRORS.valueOf(error.name());
    } catch (IllegalArgumentException x) {
      return org.jruby.ext.posix.POSIX.ERRORS.EIO; // PosixException.message has real error anyway
    }
  }
}, true);

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

private org.jruby.ext.posix.POSIX.ERRORS convert(Errno error) {
    try {
      return org.jruby.ext.posix.POSIX.ERRORS.valueOf(error.name());
    } catch (IllegalArgumentException x) {
      return org.jruby.ext.posix.POSIX.ERRORS.EIO; // PosixException.message has real error anyway
    }
  }
}, true);

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

/**
 * Create module Errno's Variables.  We have this method since Errno does not have it's
 * own java class.
 */
private void initErrno() {
  if (profile.allowModule("Errno")) {
    errnoModule = defineModule("Errno");
    try {
      // define EAGAIN now, so that future EWOULDBLOCK will alias to it
      // see MRI's error.c and its explicit ordering of Errno definitions.
      createSysErr(Errno.EAGAIN.intValue(), Errno.EAGAIN.name());
      
      for (Errno e : Errno.values()) {
        Constant c = (Constant) e;
        if (Character.isUpperCase(c.name().charAt(0))) {
          createSysErr(c.intValue(), c.name());
        }
      }
      // map ENOSYS to NotImplementedError
      errnos.put(Errno.ENOSYS.intValue(), notImplementedError);
    } catch (Exception e) {
      // dump the trace and continue
      // this is currently only here for Android, which seems to have
      // bugs in its enumeration logic
      // http://code.google.com/p/android/issues/detail?id=2812
      LOG.error(e.getMessage(), e);
    }
  }
}

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

/**
 * Create module Errno's Variables.  We have this method since Errno does not have it's
 * own java class.
 */
private void initErrno() {
  if (profile.allowModule("Errno")) {
    errnoModule = defineModule("Errno");
    try {
      // define EAGAIN now, so that future EWOULDBLOCK will alias to it
      // see MRI's error.c and its explicit ordering of Errno definitions.
      createSysErr(Errno.EAGAIN.intValue(), Errno.EAGAIN.name());
      
      for (Errno e : Errno.values()) {
        Constant c = (Constant) e;
        if (Character.isUpperCase(c.name().charAt(0))) {
          createSysErr(c.intValue(), c.name());
        }
      }
      // map ENOSYS to NotImplementedError
      errnos.put(Errno.ENOSYS.intValue(), notImplementedError);
    } catch (Exception e) {
      // dump the trace and continue
      // this is currently only here for Android, which seems to have
      // bugs in its enumeration logic
      // http://code.google.com/p/android/issues/detail?id=2812
      LOG.error(e.getMessage(), e);
    }
  }
}

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

/**
 * Create module Errno's Variables.  We have this method since Errno does not have its
 * own java class.
 */
private void initErrno() {
  if (profile.allowModule("Errno")) {
    errnoModule = defineModule("Errno");
    try {
      // define EAGAIN now, so that future EWOULDBLOCK will alias to it
      // see MRI's error.c and its explicit ordering of Errno definitions.
      createSysErr(Errno.EAGAIN.intValue(), Errno.EAGAIN.name());
      for (Errno e : Errno.values()) {
        Constant c = (Constant) e;
        if (Character.isUpperCase(c.name().charAt(0))) {
          createSysErr(c.intValue(), c.name());
        }
      }
      // map ENOSYS to NotImplementedError
      errnos.put(Errno.ENOSYS.intValue(), notImplementedError);
    } catch (Exception e) {
      // dump the trace and continue
      // this is currently only here for Android, which seems to have
      // bugs in its enumeration logic
      // http://code.google.com/p/android/issues/detail?id=2812
      LOG.error(e);
    }
  }
}

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

/**
 * Create module Errno's Variables.  We have this method since Errno does not have its
 * own java class.
 */
private void initErrno() {
  if (profile.allowModule("Errno")) {
    errnoModule = defineModule("Errno");
    try {
      // define EAGAIN now, so that future EWOULDBLOCK will alias to it
      // see MRI's error.c and its explicit ordering of Errno definitions.
      createSysErr(Errno.EAGAIN.intValue(), Errno.EAGAIN.name());
      for (Errno e : Errno.values()) {
        Constant c = (Constant) e;
        if (Character.isUpperCase(c.name().charAt(0))) {
          createSysErr(c.intValue(), c.name());
        }
      }
      // map ENOSYS to NotImplementedError
      errnos.put(Errno.ENOSYS.intValue(), notImplementedError);
    } catch (Exception e) {
      // dump the trace and continue
      // this is currently only here for Android, which seems to have
      // bugs in its enumeration logic
      // http://code.google.com/p/android/issues/detail?id=2812
      LOG.error(e);
    }
  }
}

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

/**
 * Helper for handling common POSIX situations where a negative return value
 * from a function call indicates an error, and errno must be consulted to
 * determine how exactly the function failed.
 * @param runtime Ruby runtime
 * @param result return value of a POSIX call
 */
public static void checkErrno(Ruby runtime, int result) {
  if (result < 0) {
  // FIXME: The error message is a bit off.
  // e.g., No such process - No such process (Errno::ESRCH)
  // Note the repetition of 'No such process'.
    Errno errno = Errno.valueOf(runtime.getPosix().errno());
    String name = errno.name();
    String msg  = errno.toString();
    RubyClass errnoClass = runtime.getErrno().getClass(name);
    if (errnoClass != null) {
      throw RaiseException.from(runtime, errnoClass, msg);
    }
  }
}

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

/**
 * Helper for handling common POSIX situations where a negative return value
 * from a function call indicates an error, and errno must be consulted to
 * determine how exactly the function failed.
 * @param runtime Ruby runtime
 * @param result return value of a POSIX call
 */
public static void checkErrno(Ruby runtime, int result) {
  if (result < 0) {
  // FIXME: The error message is a bit off.
  // e.g., No such process - No such process (Errno::ESRCH)
  // Note the repetition of 'No such process'.
    Errno errno = Errno.valueOf(runtime.getPosix().errno());
    String name = errno.name();
    String msg  = errno.toString();
    RubyClass errnoClass = runtime.getErrno().getClass(name);
    if (errnoClass != null) {
      throw RaiseException.from(runtime, errnoClass, msg);
    }
  }
}

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

/**
 * Helper for handling common POSIX situations where a negative return value
 * from a function call indicates an error, and errno must be consulted to
 * determine how exactly the function failed.
 * @param runtime Ruby runtime
 * @param result return value of a POSIX call
 */
public static void checkErrno(Ruby runtime, int result) {
  if (result < 0) {
  // FIXME: The error message is a bit off.
  // e.g., No such process - No such process (Errno::ESRCH)
  // Note the repetition of 'No such process'.
    Errno errno = Errno.valueOf(runtime.getPosix().errno());
    String name = errno.name();
    String msg  = errno.toString();
    RubyClass errnoClass = runtime.getErrno().getClass(name);
    if (errnoClass != null) {
      throw new RaiseException(runtime, errnoClass, msg, true);
    }
  }
}

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

/**
 * Helper for handling common POSIX situations where a negative return value
 * from a function call indicates an error, and errno must be consulted to
 * determine how exactly the function failed.
 * @param runtime Ruby runtime
 * @param result return value of a POSIX call
 */
public static void checkErrno(Ruby runtime, int result) {
  if (result < 0) {
  // FIXME: The error message is a bit off.
  // e.g., No such process - No such process (Errno::ESRCH)
  // Note the repetition of 'No such process'.
    Errno errno = Errno.valueOf(runtime.getPosix().errno());
    String name = errno.name();
    String msg  = errno.toString();
    RubyClass errnoClass = runtime.getErrno().getClass(name);
    if (errnoClass != null) {
      throw new RaiseException(runtime, errnoClass, msg, true);
    }
  }
}

相关文章