Page MenuHomeSoftware Heritage

api: Improve error handling and response management
ClosedPublic

Authored by anlambert on Thu, Oct 15, 7:36 PM.

Details

Summary

Use a custom DRF exception handler to generate an error response when an
exception is raised in a view.

Move api response creation from the api_doc decorator to the api_route one.

Remove the handle_response parameter from the api_doc decorator.

Related to T2657

Diff Detail

Repository
rDWAPPS Web applications
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

anlambert created this revision.Thu, Oct 15, 7:36 PM

Build is green

Patch application report for D4276 (id=15122)

Rebasing onto d948e60ecd...

Current branch diff-target is up to date.
Changes applied before test
commit 65339606f4a1868665d0355beac7b5d6d0fa84ea
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 16:44:55 2020 +0200

    api: Improve error handling and response management
    
    Use a custom DRF exception handler to generate an error response when an
    exception is raised in a view.
    
    Move api response creation from the api_doc decorator to the api_route one.
    
    Remove the handle_response parameter from the api_doc decorator.
    
    Related to T2657

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/414/ for more details.

vlorentz accepted this revision.Thu, Oct 15, 8:00 PM
vlorentz added a subscriber: vlorentz.
vlorentz added inline comments.
swh/web/api/apiresponse.py
214

equivalent to: doc_data = getattr(exc, "doc_data", None)

This revision is now accepted and ready to land.Thu, Oct 15, 8:00 PM
anlambert updated this revision to Diff 15128.Thu, Oct 15, 9:57 PM

Apply @vlorentz comment.

Build is green

Patch application report for D4276 (id=15128)

Rebasing onto d948e60ecd...

Current branch diff-target is up to date.
Changes applied before test
commit bd8b47d67345028ac843034cdcbe602e11e28c95
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 16:44:55 2020 +0200

    api: Improve error handling and response management
    
    Use a custom DRF exception handler to generate an error response when an
    exception is raised in a view.
    
    Move api response creation from the api_doc decorator to the api_route one.
    
    Remove the handle_response parameter from the api_doc decorator.
    
    Related to T2657

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/419/ for more details.

Build is green

Patch application report for D4276 (id=15248)

Rebasing onto 7fbb185005...

Current branch diff-target is up to date.
Changes applied before test
commit 7c5e04cca483dda98c76d7482a7c345a03107676
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 16:44:55 2020 +0200

    api: Improve error handling and response management
    
    Use a custom DRF exception handler to generate an error response when an
    exception is raised in a view.
    
    Move api response creation from the api_doc decorator to the api_route one.
    
    Remove the handle_response parameter from the api_doc decorator.
    
    Related to T2657

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/422/ for more details.