Exception: SkyZabbix::Jsonrpc::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sky_zabbix/jsonrpc/errors.rb

Defined Under Namespace

Classes: BatchError, InternalError, InvalidParams, InvalidRequest, MethodNotFound, ParseError, ServerError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ Error

Returns a new instance of Error.


2
3
4
5
6
# File 'lib/sky_zabbix/jsonrpc/errors.rb', line 2

def initialize(body)
  @error = body['error']
  msg = "#{@error['message']} #{@error['data']}"
  super(msg)
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error


7
8
9
# File 'lib/sky_zabbix/jsonrpc/errors.rb', line 7

def error
  @error
end

Class Method Details

.create(body) ⇒ Object


16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sky_zabbix/jsonrpc/errors.rb', line 16

def self.create(body)
  klass =
    case body['code']
    when -32700;         ParseError
    when -32600;         InvalidRequest
    when -32601;         MethodNotFound
    when -32602;         InvalidParams
    when -32603;         InternalError
    when -32099..-32000; ServerError
    else;                self
    end
  klass.new(body)
end