Exception: Simplify::BadRequestException
- Inherits:
-
ApiException
- Object
- Exception
- ApiException
- Simplify::BadRequestException
- Defined in:
- lib/simplify/apiexception.rb
Overview
Exception representing invalid requests made to the API.
Defined Under Namespace
Classes: FieldError
Instance Attribute Summary collapse
-
#fieldErrors ⇒ Object
readonly
List of field errors associatied with this error (empty if there are no field errors).
Attributes inherited from ApiException
#errorCode, #errorData, #errorMessage, #reference, #status
Instance Method Summary collapse
-
#describe ⇒ Object
Returns a string description of the error including any field errors.
-
#hasFieldErrors? ⇒ Boolean
Returns boolean indicating if there are field errors associated with this API error.
-
#initialize(message, status, errorData) ⇒ BadRequestException
constructor
A new instance of BadRequestException.
- #super_describe ⇒ Object
Constructor Details
#initialize(message, status, errorData) ⇒ BadRequestException
Returns a new instance of BadRequestException.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/simplify/apiexception.rb', line 116 def initialize(, status, errorData) super(, status, errorData) @fieldErrors = [] if errorData.has_key?('error') error = errorData['error'] if error.has_key?('fieldErrors') fieldErrors = error['fieldErrors'] fieldErrors.each do |fieldError| @fieldErrors << FieldError.new(fieldError) end end end end |
Instance Attribute Details
#fieldErrors ⇒ Object (readonly)
List of field errors associatied with this error (empty if there are no field errors).
112 113 114 |
# File 'lib/simplify/apiexception.rb', line 112 def fieldErrors @fieldErrors end |
Instance Method Details
#describe ⇒ Object
Returns a string description of the error including any field errors.
138 139 140 141 142 143 144 |
# File 'lib/simplify/apiexception.rb', line 138 def describe() s = super_describe() @fieldErrors.each do |fieldError| s = s + "\n" + fieldError.to_s end return s + "\n" end |
#hasFieldErrors? ⇒ Boolean
Returns boolean indicating if there are field errors associated with this API error.
133 134 135 |
# File 'lib/simplify/apiexception.rb', line 133 def hasFieldErrors? return @fieldErrors.length > 1 end |
#super_describe ⇒ Object
114 |
# File 'lib/simplify/apiexception.rb', line 114 alias :super_describe :describe |