Class: GlobusClient::UnexpectedResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/globus_client/unexpected_response.rb

Overview

Handles unexpected responses when communicating with Globus

Class Method Summary collapse

Class Method Details

.call(response) ⇒ Object

Parameters:

  • response (Faraday::Response)


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/globus_client/unexpected_response.rb', line 11

def self.call(response)
  case response.status
  when 400
    raise GlobusClient::BadRequestError, "Invalid path or another error with the request: #{response.body}"
  when 401
    raise GlobusClient::UnauthorizedError, "There was a problem with the access token: #{response.body} "
  when 403
    raise GlobusClient::ForbiddenError, "The operation requires privileges which the client does not have: #{response.body}"
  when 404
    raise GlobusClient::ResourceNotFound, "Endpoint ID not found or resource does not exist: #{response.body}"
  when 502
    raise GlobusClient::EndpointError, "Other error with endpoint: #{response.status} #{response.body}."
  when 503
    raise GlobusClient::ServiceUnavailable, 'The service is down for maintenance.'
  else
    raise GlobusClient::InternalServerError, "Unexpected response: #{response.status} #{response.body}."
  end
end