Exception: Simplify::ApiException
- Inherits:
-
Exception
- Object
- Exception
- Simplify::ApiException
- Defined in:
- lib/simplify/apiexception.rb
Overview
Base class for all API exceptions.
Direct Known Subclasses
AuthenticationException, BadRequestException, NotAllowedException, ObjectNotFoundException, SystemException
Instance Attribute Summary collapse
-
#errorCode ⇒ Object
readonly
API code for the error.
-
#errorData ⇒ Object
readonly
Error data returned from the API represented as a map.
-
#errorMessage ⇒ Object
readonly
Description of the error.
-
#reference ⇒ Object
readonly
Unique reference ID for the API error.
-
#status ⇒ Object
readonly
HTML status code (or nil if there is no status code).
Instance Method Summary collapse
-
#describe ⇒ Object
Returns a string descrption of the error.
-
#initialize(message, status, errorData) ⇒ ApiException
constructor
A new instance of ApiException.
Constructor Details
#initialize(message, status, errorData) ⇒ ApiException
Returns a new instance of ApiException.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/simplify/apiexception.rb', line 49 def initialize(, status, errorData) super() @status = status @errorMessage = @fieldErrors = [] if errorData != nil @errorData = errorData @reference = errorData.has_key?('reference') ? errorData['reference'] : nil if errorData.has_key?('error') error = errorData['error'] @errorCode = error['code'] if error.has_key?('message') = error['message'] end end end super() end |
Instance Attribute Details
#errorCode ⇒ Object (readonly)
API code for the error.
44 45 46 |
# File 'lib/simplify/apiexception.rb', line 44 def errorCode @errorCode end |
#errorData ⇒ Object (readonly)
Error data returned from the API represented as a map.
38 39 40 |
# File 'lib/simplify/apiexception.rb', line 38 def errorData @errorData end |
#errorMessage ⇒ Object (readonly)
Description of the error.
47 48 49 |
# File 'lib/simplify/apiexception.rb', line 47 def errorMessage @errorMessage end |
#reference ⇒ Object (readonly)
Unique reference ID for the API error.
41 42 43 |
# File 'lib/simplify/apiexception.rb', line 41 def reference @reference end |
#status ⇒ Object (readonly)
HTML status code (or nil if there is no status code)
35 36 37 |
# File 'lib/simplify/apiexception.rb', line 35 def status @status end |
Instance Method Details
#describe ⇒ Object
Returns a string descrption of the error.
71 72 73 |
# File 'lib/simplify/apiexception.rb', line 71 def describe() return "#{self.class}: \"#{self.to_s()}\" (status: #{@status}, error code #{@errorCode}, reference: #{@reference})" end |