Exception: Simplify::BadRequestException

Inherits:
ApiException
  • Object
show all
Defined in:
lib/simplify/apiexception.rb

Overview

Exception representing invalid requests made to the API.

Defined Under Namespace

Classes: FieldError

Instance Attribute Summary collapse

Attributes inherited from ApiException

#errorCode, #errorData, #errorMessage, #reference, #status

Instance Method Summary collapse

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(message, status, errorData)

  super(message, 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

#fieldErrorsObject (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

#describeObject

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.

Returns:

  • (Boolean)


133
134
135
# File 'lib/simplify/apiexception.rb', line 133

def hasFieldErrors?
    return @fieldErrors.length > 1
end

#super_describeObject



114
# File 'lib/simplify/apiexception.rb', line 114

alias :super_describe :describe