Method: Booqable::Error.error_for_400

Defined in:
lib/booqable/error.rb

.error_for_400(response) ⇒ Object

Return most appropriate error for 400 HTTP status code rubocop:disable Metrics/CyclomaticComplexity



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/booqable/error.rb', line 88

def self.error_for_400(response)
  case response.body
  when /unwrittable_attribute/i
    Booqable::ReadOnlyAttribute
  when /unknown_attribute/i
    Booqable::UnknownAttribute
  when /extra fields should be an object/i
    Booqable::ExtraFieldsInWrongFormat
  when /fields should be an object/i
    Booqable::FieldsInWrongFormat
  when /page should be an object/i
    Booqable::PageShouldBeAnObject
  when /failed typecasting/i
    Booqable::FailedTypecasting
  when /invalid filter/i
    Booqable::InvalidFilter
  when /required filter/i
    Booqable::RequiredFilter
  when /invalid_grant/i
    error_for_invalid_grant(response)
  else
    Booqable::BadRequest
  end
end