Exception: DemoApiScalarGalaxy::Errors::APIStatusError

Inherits:
APIError
  • Object
show all
Defined in:
lib/amritk-galaxy-staging/errors.rb,
sig/amritk-galaxy-staging/errors.rbs

Instance Attribute Summary collapse

Attributes inherited from APIError

#body, #headers, #url

Attributes inherited from Error

#cause

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, status:, headers:, 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)
  • headers (Hash{String=>String}, nil)
  • body (Object, nil)
  • request (nil)
  • response (nil)
  • message (String, nil) (defaults to: nil)


181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/amritk-galaxy-staging/errors.rb', line 181

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

Instance Attribute Details

#status ⇒ Integer

Returns:

  • (Integer)


# File 'lib/amritk-galaxy-staging/errors.rb', line 168

Class Method Details

.for(url:, status:, headers:, 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)
  • headers (Hash{String=>String}, nil)
  • body (Object, nil)
  • request (nil)
  • response (nil)
  • message (String, nil) (defaults to: nil)

Returns:

  • (self)


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
# File 'lib/amritk-galaxy-staging/errors.rb', line 135

def self.for(url:, status:, headers:, body:, request:, response:, message: nil)
  kwargs = {
    url: url,
    status: status,
    headers: headers,
    body: body,
    request: request,
    response: response,
    message: message
  }

  case status
  in 400
    DemoApiScalarGalaxy::Errors::BadRequestError.new(**kwargs)
  in 401
    DemoApiScalarGalaxy::Errors::AuthenticationError.new(**kwargs)
  in 403
    DemoApiScalarGalaxy::Errors::PermissionDeniedError.new(**kwargs)
  in 404
    DemoApiScalarGalaxy::Errors::NotFoundError.new(**kwargs)
  in 409
    DemoApiScalarGalaxy::Errors::ConflictError.new(**kwargs)
  in 422
    DemoApiScalarGalaxy::Errors::UnprocessableEntityError.new(**kwargs)
  in 429
    DemoApiScalarGalaxy::Errors::RateLimitError.new(**kwargs)
  in 500.. then
    DemoApiScalarGalaxy::Errors::InternalServerError.new(**kwargs)
  else
    DemoApiScalarGalaxy::Errors::APIStatusError.new(**kwargs)
  end
end