Sha256: 6c22e52505fca9d976a4cda91d9a4ef3fe9cb916e918eaf02132633793dfcf6f
Contents?: true
Size: 859 Bytes
Versions: 1
Compression:
Stored size: 859 Bytes
Contents
# frozen_string_literal: true class MaisOrcidClient # Handles unexpected responses when communicating with Mais class UnexpectedResponse # Error raised when the Mais API returns a 401 Unauthorized class UnauthorizedError < StandardError; end # Error raised when the Mais API returns a 500 error class ServerError < StandardError; end # Error raised when the Mais API returns a response with an error message in it class ResponseError < StandardError; end def self.call(response) case response.status when 401 raise UnauthorizedError, "There was a problem with the access token: #{response.body}" when 500 raise ServerError, "Mais server error: #{response.body}" else raise StandardError, "Unexpected response: #{response.status} #{response.body}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mais_orcid_client-0.3.1 | lib/mais_orcid_client/unexpected_response.rb |