-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Labels
Description
The response_body field of the ApiError class is always a string - but sometimes it's a JSON string, and sometimes not.
So, to extract a meaningful error message i have to do something like:
message =
if error.response_headers['Content-Type'].include?('application/json')
JSON.parse(error.response_body).dig('message')
else
error.response_body
end
It seems parsing the response from the API should be a concern of the ApiError Class, what do you think about adding something that does this to the ApiError class? I'm happy to submit a PR if you like the idea.