Closed bekab95 closed 6 years ago
There are already blueprint error handlers.
I need to handle page not found but it refers to app not blueprint and can you provide more clear examples or documentation on this ? thanks
@davidism 404 and 405 from routing are not caught by blueprint-level handlers.
@ufo911 this is not possible due to the way blueprints work. A blueprint does not "own" a certain URL segment, even when using url_prefix
which I believe you do. The reason for this is simple: It's perfectly valid to have the same url_prefix
on multiple blueprints since it simply gets prepended to the path specified in the route()
call.
We have no intentions of changing this behavior, as it would possibly break all kinds of use cases in bigger apps.
However, I think we should consider adding a way of registering an error handler for a base URL so you could do something like @app.errorhandler(NotFound, path='/api/')
@ThiefMaster thanks for answer ! https://stackoverflow.com/questions/49496761/two-language-flask-site-with-or-without-blueprints/49948870#49948870 My app example is this, I was trying to get multiple lang site for about 2-3 months and got that solution on my own (in documentation there are so little examples) now I am stuck on error handling, I can share full project with you to see (it is not big) I had to have after requests for cookie for lang and other little things to handle languages and it is bit tricky and not standard way to handle application problems I think.. can you tell me more about this ?
However, I think we should consider adding a way of registering an error handler for a base URL so you could do something like @app.errorhandler(NotFound, path='/api/')
Please add error handlers to Blueprint (404 and others) For multi language Site I had to write app error handlers and cookies and after requests with session and cookie and a bit mess in my code so may error handling inside blueprint is good idea
Thanks