You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Hey @jaredmoody, I'd be happy to see this enhancement and to accept a PR implementing the change, I'll note that this gem is generated via openapi-generator using a combined spec produced from Save-ConnectWiseApiSpecs.ps1.
I'm thinking that the change would have to be an override in order to limit manual changes to the code that's autogenerated.
Activity
sowderca commentedon Sep 24, 2019
Hey @jaredmoody, I'd be happy to see this enhancement and to accept a PR implementing the change, I'll note that this gem is generated via openapi-generator using a combined spec produced from Save-ConnectWiseApiSpecs.ps1.
I'm thinking that the change would have to be an override in order to limit manual changes to the code that's autogenerated.
Let me know what you think