flask-smorest icon indicating copy to clipboard operation
flask-smorest copied to clipboard

Reasoning for Errorhandlers on the API vs Blueprint

Open jrast opened this issue 3 years ago • 2 comments

Currently the errorhandlers are added on a application basis via the ErrorHandlerMixin on the API class. Flask also allows to define the error handlers on the Blueprint level. What is the reasoning to use application level error handlers?

I can see the following pros/cons:

Pro:

  • Simplicity: single registration on the application level
  • Handling of unknown routes

Con:

  • Can hide user defined error handlers or can be hidden by user defined handlers.
  • Also applies to non API Routes
  • Currently no mention in the docs that the handlers are registered on the application level.

jrast avatar Jul 28 '20 18:07 jrast

Hi. Thanks for the constructive feedback. I'm pretty busy these days so I can't promise I'll provide quick answers.

This was partly discussed in #51. I closed the issue back then but I'm open to reconsidering.

lafrech avatar Jul 28 '20 20:07 lafrech

No problem. I'm just evaluating flask-smorest at the moment, comming from something self made. During the migration phase it would be nice if the error handlers just intercepts the errors on the new API.

jrast avatar Jul 28 '20 20:07 jrast