Exception: AgileCRMWrapper::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/agilecrm-wrapper/error.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, message = '') ⇒ Error

Returns a new instance of Error.



22
23
24
25
# File 'lib/agilecrm-wrapper/error.rb', line 22

def initialize(response, message = '')
  super(message)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



3
4
5
# File 'lib/agilecrm-wrapper/error.rb', line 3

def response
  @response
end

Class Method Details

.errorsObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/agilecrm-wrapper/error.rb', line 10

def errors
  @errors ||= {
    400 => AgileCRMWrapper::BadRequest,
    401 => AgileCRMWrapper::Unauthorized,
    404 => AgileCRMWrapper::NotFound,
    405 => AgileCRMWrapper::MethodNotAllowed,
    415 => AgileCRMWrapper::MediaTypeMismatch,
    500 => AgileCRMWrapper::InternalServerError
  }
end

.from_response(response, message = '') ⇒ Object



6
7
8
# File 'lib/agilecrm-wrapper/error.rb', line 6

def from_response(response, message = '')
  new(response, message)
end