Design updates with error handling
This commit is contained in:
1 parent
4c73608549
commit
4b84df0af9
9 files changed
+124
-38
No files matched your search
@@ -19,13 +19,21 @@ module StrikeMe
|
||||
end
|
||||
|
||||
# cumbersome, but better for later debugging and handling
|
||||
class ResponseError
|
||||
attr_reader :url, :faraday_response
|
||||
class ResponseError < StandardError
|
||||
attr_reader :url, :response_body, :status, :reason
|
||||
|
||||
def initialize(url, faraday_response)
|
||||
def initialize(url, response_body)
|
||||
@reason = response_body.try(:[], 'data').try(:[], 'message')
|
||||
@status = response_body.try(:[], 'data').try(:[], 'status')
|
||||
|
||||
super "[#{status}, {}, [\"#{reason}\"]]" if reason
|
||||
@url = url
|
||||
@faraday_response = faraday_response
|
||||
@response_body = response_body
|
||||
end
|
||||
|
||||
# def inspect
|
||||
# "StrikeMe::API::BaseClient::ResponseError: #{url} status: #{faraday_response.status}"
|
||||
# end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user