Sha256: 15537501813154cca0c11b63d2834813faa1ad80564cfb6f81ce77c974d90683
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
module ZMQ # A hash of error number => exception class. # Example: 1 => Errno::EPERM @error_map = Hash.new Errno.constants .map { |x| Errno.const_get x } .select { |x| x.is_a?(Class) && x < SystemCallError } .each { |x| @error_map[x.const_get(:Errno)] = x } # Checks the libzmq global error number and raises it as an exception. # Should be used after calling a libzmq resource that returns -1 on error. # Example: ZMQ.error_check if rc == -1 def self.error_check(adjust_backtrace=false) errno = LibZMQ.zmq_errno return true if errno == 25 # TODO: What is this for? Remove? backtrace = adjust_backtrace ? caller[0...-2] : caller if @error_map.has_key? errno raise @error_map[errno], '', backtrace else raise SystemCallError, errno.to_s, backtrace end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
0mq-0.5.2 | lib/0mq/error_check.rb |