Class: GlobusClient::UnexpectedResponse

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

Overview

Handles unexpected responses when communicating with Globus

Defined Under Namespace

Classes: BadRequestError, EndpointError, ForbiddenError, ResourceNotFound, ServiceUnavailable, UnauthorizedError

Class Method Summary collapse

Class Method Details

.call(response) ⇒ Object

Parameters:

  • response (Faraday::Response)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/globus_client/unexpected_response.rb', line 29

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