class Whatconverts::ErrorChecker
Attributes
api_response[R]
Public Class Methods
new(api_response)
click to toggle source
# File lib/whatconverts/error_checker.rb, line 6 def initialize(api_response) @api_response = api_response end
Public Instance Methods
error_if_appropriate()
click to toggle source
# File lib/whatconverts/error_checker.rb, line 10 def error_if_appropriate return AuthError.new(response_body) if is_auth_error? return ApiError.new(response_body) if is_error? end
Private Instance Methods
is_auth_error?()
click to toggle source
# File lib/whatconverts/error_checker.rb, line 17 def is_auth_error? api_response.status.to_i == 401 end
is_error?()
click to toggle source
# File lib/whatconverts/error_checker.rb, line 21 def is_error? api_response.status.to_i >= 400 end
response_body()
click to toggle source
# File lib/whatconverts/error_checker.rb, line 25 def response_body JSON.parse(api_response.body)['error_message'] rescue api_response.body end