Reorganise under Linux::
This commit is contained in:
15
lib/linux/error.rb
Normal file
15
lib/linux/error.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
module Linux
|
||||
ERRNO_MAP = {} #:nodoc:
|
||||
Errno.constants.each do |k|
|
||||
klass = Errno.const_get(k)
|
||||
next unless klass.is_a?(Class) and Class.const_defined?(:Errno)
|
||||
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
|
Reference in New Issue
Block a user