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