Exception: MC2P::MC2PError

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

Overview

MC2P Error - class used to manage the exceptions related with mc2p library

Direct Known Subclasses

BadUseError, InvalidRequestError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, json_body = nil, resource = nil, resource_id = nil) ⇒ MC2PError

Initializes an error Params:

message

Error type

json_body

Response from server

resource

Class resource used when the error raised

resource_id

Resource id requested when the error raised



14
15
16
17
18
19
20
21
22
# File 'lib/errors.rb', line 14

def initialize(message = nil, json_body = nil,
               resource = nil, resource_id = nil)
  super(message)

  @_message = message
  @json_body = json_body
  @resource = resource
  @resource_id = resource_id
end

Instance Attribute Details

#json_bodyObject

Returns the value of attribute json_body.



4
5
6
# File 'lib/errors.rb', line 4

def json_body
  @json_body
end

#resourceObject

Returns the value of attribute resource.



5
6
7
# File 'lib/errors.rb', line 5

def resource
  @resource
end

#resource_idObject

Returns the value of attribute resource_id.



6
7
8
# File 'lib/errors.rb', line 6

def resource_id
  @resource_id
end

Instance Method Details

#to_sObject

Returns: Error type and response



25
26
27
# File 'lib/errors.rb', line 25

def to_s
  "#{@_message} #{@json_body}"
end