Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General | Enhance Error Handling #154

Merged
merged 1 commit into from Nov 22, 2022
Merged

General | Enhance Error Handling #154

merged 1 commit into from Nov 22, 2022

Conversation

tom-ioki
Copy link
Contributor

At the moment, ioki-ruby is not able to handle errors that have a non-json response body (e.g. some errors like 404 - ActiveRecord::RecordNotFound come with a 'text/html' response body). Reason being, the JsonParse middleware of Faraday tries to parse the response body to json no matter what. This however causes ioki-ruby to raise a Faraday::ParsingError when the response body is not a json.

This PR will add the content_typ setting to the JsonParse middleware of Faraday which ensures that only response bodies of type json will be parsed. Response bodies of any other type will not be parsed and thus will not raise the infamous Faraday::ParsingError.

@rmehner
Copy link
Collaborator

rmehner commented Nov 22, 2022

Neat. We should put out a new release soon :)

@tom-ioki tom-ioki merged commit b37c044 into main Nov 22, 2022
@tom-ioki tom-ioki deleted the enhance-error-handling branch November 22, 2022 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants