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

Support for customer error handling #3

Closed
timbogit opened this issue Jun 11, 2020 · 3 comments
Closed

Support for customer error handling #3

timbogit opened this issue Jun 11, 2020 · 3 comments

Comments

@timbogit
Copy link
Contributor

The underlying stoplight gem support custom error handling via the .with_error_handler method.
It would be very useful for my use case to add an option to this Faraday middleware that allows for passing such a costum error handler, as it would be great to allow for particular error types to be exempt from tripping the circuit breaker (like regular 403 or 401 responses from downstream services, which aren't really out-of-the-ordinary conditions that should trip the breaker).

E.g., we have code elsewhere using stoplight that does something like this to exempt the NON_TRIPPING error classes from tripping the breaker:

    Stoplight(name, &block)
      .with_threshold(MY_THRESHOLD)
      .with_error_handler do |error, handle|
        raise error if NON_TRIPPING_ERRORS.any? { |exempt_err| error.is_a?(exempt_err) }
        handle.call(error)
      end
     .run

This issue is a request to add an error_handler option with similar behavior to this middleware, where the default error handler would just be Stoplight::Default::ERROR_HANDLER

@timbogit
Copy link
Contributor Author

@gottfrois / @knapo : is this gem still maintained?
If so, are you accepting PRs for this issue?

@gottfrois
Copy link
Member

hey @timbogit
Long time we haven't pushed anything to master but I'll gladly accept PRs!

@timbogit
Copy link
Contributor Author

Thanks, @gottfrois !

I spun up #4 to add this feature.
Please let me know your feedback and - if deemed acceptable - if and when you could issue this gem version.

Thanks!

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