Page MenuHomeSoftware Heritage

api: Improve error handling and response management
ClosedPublic

Authored by anlambert on Oct 15 2020, 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
Branch
api-error-management-rework
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 16349
Build 25173: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 25172: arc lint + arc unit

Event Timeline

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 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.Oct 15 2020, 8:00 PM

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.