Files
netlinkrb/lib/linux/error.rb

16 lines
380 B
Ruby
Raw Normal View History

2011-05-06 09:49:47 +01:00
module Linux
ERRNO_MAP = {} #:nodoc:
Errno.constants.each do |k|
klass = Errno.const_get(k)
2011-05-06 13:40:41 +01:00
next unless klass.is_a?(Class) and klass.const_defined?(:Errno)
2011-05-06 09:49:47 +01:00
ERRNO_MAP[klass::Errno] = klass
end
# Raise an Errno exception if the given rc is negative
def self.check_error(rc)
if rc < 0
raise ERRNO_MAP[-rc] || "System error #{-rc}"
end
end
end