Exception: RbZMQ::ZMQError

Inherits:
Error
  • Object
show all
Defined in:
lib/rbzmq/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rc, errno = nil, message = nil) ⇒ ZMQError


10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rbzmq/errors.rb', line 10

def initialize(rc, errno = nil, message = nil)
  if ZMQ::ZeroMQError === rc
    @rc      = rc.result_code
    @errno   = rc.error_code
    @message = rc.message =~ /msg\s+\[(.*?)\]/ ? $1 : 'Unknown'
  else
    @rc      = rc
    @errno   = errno || ZMQ::Util.errno
    @message = message || ZMQ::Util.error_string
  end

  super "[ERRNO #{@errno}, RC #{@rc}] #{@message}"
end

Instance Attribute Details

#errnoObject (readonly) Also known as: error_code

Returns the value of attribute errno


8
9
10
# File 'lib/rbzmq/errors.rb', line 8

def errno
  @errno
end

#messageObject (readonly)

Returns the value of attribute message


8
9
10
# File 'lib/rbzmq/errors.rb', line 8

def message
  @message
end

#rcObject (readonly) Also known as: result_code

Returns the value of attribute rc


8
9
10
# File 'lib/rbzmq/errors.rb', line 8

def rc
  @rc
end

Class Method Details

.error!(rc) ⇒ Object


28
29
30
31
32
33
34
# File 'lib/rbzmq/errors.rb', line 28

def error!(rc)
  if error?(rc)
    raise new(rc)
  else
    rc
  end
end

.error?(rc) ⇒ Boolean


36
37
38
# File 'lib/rbzmq/errors.rb', line 36

def error?(rc)
  -1 == rc
end

.ok?(rc) ⇒ Boolean


40
41
42
# File 'lib/rbzmq/errors.rb', line 40

def ok?(rc)
  !error? rc
end