-
Notifications
You must be signed in to change notification settings - Fork 67
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
Not Raising on Server Side errors #138
Comments
Hello @djpate, great question! Out of the box, Spyke makes no assumptions about what to do with different status codes and only cares about the content of the hash passed in via Faraday: { data: { id: 1, name: 'Bob' }, metadata: {}, errors: {} } This will raise a Line 30 in 9d256d4
...or an empty array if trying to find multiple and not seeing any: Lines 36 to 38 in 9d256d4
You can tweak your Faraday middleware to define custom behavior around specific http status codes. class Middleware::ErrorHandler < Faraday::Middleware
def call(env)
@app.call(env).on_complete do
raise Spyke::ConnectionError, env[:body] unless env.success?
end
end
end Hope that helps! Otherwise feel free to ask again 👍 |
Hello,
I've been battling with an issue where the gem won't raise on a 500+ error.
Right now the gem raises on Timeout and Connection Failed I believe but If the response is a 500 or a 404 or 401 it automatically fallsback to an empty array which is not what I would expect since I'm not using the with_fallback option.
What is the best way to handle this?
The text was updated successfully, but these errors were encountered: