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().fastGetClass(name);
if (errnoClass != null) {
throw new RaiseException(runtime, errnoClass, msg, true);
}
}