skychyld / copr / copr

Forked from copr/copr 5 years ago
Clone

dddc4ad [frontend] rework error handlers to fix #531

6 files Authored by frostyx 5 years ago, Committed by msuchy 5 years ago,
    [frontend] rework error handlers to fix #531
    
    There are multiple issues with our current implementation
    of error handling.
    
    First, `apiv3_ns` defines error handlers on application level,
    not blueprint level. This causes the #531 issue and results in
    showing API errors even for exceptions, that happened in UI.
    
    Also, `coprs_ns` defines error handler for 404, but only for the case,
    that some object is not found. It doesn't cover the case when
    a whole API endpoint is not found. We can't add it there, though.
    According to the Flask documentation
    http://flask.pocoo.org/docs/1.0/blueprints/#error-handlers
    it is not possible to add handlers for 404 and 405 on blueprint level.
    That's why it is currently implemented in `misc.py`.
    
    That basically means, that our error handlers are inconsistently spread
    within the application and we need to have some of them for `apiv3_ns`
    and `coprs_ns` blueprints and also a conditioned handler for 404 on
    application level. I have had multiple moments of clarity, thinking
    that I finally understand how the code works, but I didn't. And then
    again and gain, so I decided to rather have all handlers implemented
    the same way.