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

Faraday Errors hide the response body #19

Open
enriquez opened this issue Sep 16, 2024 · 1 comment
Open

Faraday Errors hide the response body #19

enriquez opened this issue Sep 16, 2024 · 1 comment

Comments

@enriquez
Copy link

We were getting a Faraday::BadRequestError: the server responded with status 400 error when trying to create a user. Since the exception is being thrown, we don't have an easy way to see the response body which would give us details on what we're doing wrong.

Is there a way to get an error's response body when making an API call? Maybe have an option to remove the raise_errors in the Faraday connection?

@julik
Copy link

julik commented Feb 6, 2025

If I look at the Faraday middleware (don't remember whether we use the same version here or not though) - here - https://github.com/lostisland/faraday/blob/main/lib/faraday/response/raise_error.rb - you will see that the raised error contains various request/response attributes, among them - the response body (via response_values). Is that usable for your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants