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

ExceptionFilterAttribute doesn't get hit #20

Open
stevengopmo opened this issue Apr 11, 2018 · 1 comment
Open

ExceptionFilterAttribute doesn't get hit #20

stevengopmo opened this issue Apr 11, 2018 · 1 comment
Labels

Comments

@stevengopmo
Copy link
Contributor

I've noticed that my Custom ExceptionFilterAttribute doesn't get hit when using this approach to WebApi. Maybe that's the reason you have a try catch in the DelegatingHandlers? Do you know why the normal filtering mechanism doesn't work with this approach? In general, I'm kind of anti try/catch and I think the built-in WebApi approach is generally pretty decent.

Of course, this one small place for catching isn't bad; I guess I'm curious if there's a technical reason.

@dotnetjunkie
Copy link
Owner

To be honest, I don't know, but I can imagine that exception filters only work on controllers. At a broader level, I think you'd stack delegating handlers (as decorators) to apply exception filtering. As a simplification, this project places the exception handling inside the single delegating handler, because:

  • that's the simplest thing that could possibly work
  • having try-catch statements makes it very clear how things are handled (compared to exception filters, which always freak me out a bit), and it gives you full control.
  • In case the generic handling becomes too much, it can be easily refactored into smaller methods, or even extracted into delegating handlers.

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

No branches or pull requests

2 participants