Exception: Orb::Errors::APIStatusError

Inherits:
APIError
  • Object
show all
Defined in:
lib/orb/errors.rb

Instance Attribute Summary collapse

Attributes inherited from APIError

#body, #url

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, status:, body:, request:, response:, message: nil) ⇒ APIStatusError

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of APIStatusError.

Parameters:

  • url (URI::Generic)
  • status (Integer)
  • body (Object, nil)
  • request (nil)
  • response (nil)
  • message (String, nil) (defaults to: nil)


194
195
196
197
198
199
200
201
202
203
204
# File 'lib/orb/errors.rb', line 194

def initialize(url:, status:, body:, request:, response:, message: nil)
  message ||= {url: url.to_s, status: status, body: body}
  super(
    url: url,
    status: status,
    body: body,
    request: request,
    response: response,
    message: message&.to_s
  )
end

Instance Attribute Details

#statusInteger

Returns:

  • (Integer)


2
3
4
# File 'lib/orb/errors.rb', line 2

def status
  @status
end

Class Method Details

.for(url:, status:, body:, request:, response:, message: nil) ⇒ self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • url (URI::Generic)
  • status (Integer)
  • body (Object, nil)
  • request (nil)
  • response (nil)
  • message (String, nil) (defaults to: nil)

Returns:

  • (self)


125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/orb/errors.rb', line 125

def self.for(url:, status:, body:, request:, response:, message: nil)
  key = Orb::Internal::Util.dig(body, :type)
  kwargs = {
    url: url,
    status: status,
    body: body,
    request: request,
    response: response,
    message: message
  }

  case [status, key]
  in [400, Orb::Errors::ConstraintViolation::TYPE]
    Orb::Errors::ConstraintViolation.new(**kwargs)
  in [400, Orb::Errors::DuplicateResourceCreation::TYPE]
    Orb::Errors::DuplicateResourceCreation.new(**kwargs)
  in [400, Orb::Errors::FeatureNotAvailable::TYPE]
    Orb::Errors::FeatureNotAvailable.new(**kwargs)
  in [400, Orb::Errors::RequestValidationError::TYPE]
    Orb::Errors::RequestValidationError.new(**kwargs)
  in [401, Orb::Errors::OrbAuthenticationError::TYPE]
    Orb::Errors::OrbAuthenticationError.new(**kwargs)
  in [404, Orb::Errors::ResourceNotFound::TYPE]
    Orb::Errors::ResourceNotFound.new(**kwargs)
  in [404, Orb::Errors::URLNotFound::TYPE]
    Orb::Errors::URLNotFound.new(**kwargs)
  in [409, Orb::Errors::ResourceConflict::TYPE]
    Orb::Errors::ResourceConflict.new(**kwargs)
  in [413, Orb::Errors::RequestTooLarge::TYPE]
    Orb::Errors::RequestTooLarge.new(**kwargs)
  in [413, Orb::Errors::ResourceTooLarge::TYPE]
    Orb::Errors::ResourceTooLarge.new(**kwargs)
  in [429, Orb::Errors::TooManyRequests::TYPE]
    Orb::Errors::TooManyRequests.new(**kwargs)
  in [(500..), Orb::Errors::OrbInternalServerError::TYPE]
    Orb::Errors::OrbInternalServerError.new(**kwargs)
  in [400, _]
    Orb::Errors::BadRequestError.new(**kwargs)
  in [401, _]
    Orb::Errors::AuthenticationError.new(**kwargs)
  in [403, _]
    Orb::Errors::PermissionDeniedError.new(**kwargs)
  in [404, _]
    Orb::Errors::NotFoundError.new(**kwargs)
  in [409, _]
    Orb::Errors::ConflictError.new(**kwargs)
  in [422, _]
    Orb::Errors::UnprocessableEntityError.new(**kwargs)
  in [429, _]
    Orb::Errors::RateLimitError.new(**kwargs)
  in [(500..), _]
    Orb::Errors::InternalServerError.new(**kwargs)
  else
    Orb::Errors::APIStatusError.new(**kwargs)
  end
end