Page MenuHomeSoftware Heritage

django: Improve error handling
ClosedPublic

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

Details

Summary

Use a dedicated django middleware to handle uncaught exception raised when
processing a view and generate error response.

Related to T2657

Depends on D4276

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
anlambert updated this revision to Diff 15125.Thu, Oct 15, 7:44 PM

Update commit message

anlambert retitled this revision from browse: Improve error handling to django: Improve error handling.Thu, Oct 15, 7:44 PM

Build is green

Patch application report for D4277 (id=15123)

Could not rebase; Attempt merge onto d948e60ecd...

Updating d948e60e..706829d8
Fast-forward
 swh/web/api/apidoc.py                    |  24 +--
 swh/web/api/apiresponse.py               |  61 ++++---
 swh/web/api/apiurls.py                   |  44 +++--
 swh/web/api/views/content.py             |   2 +-
 swh/web/api/views/origin_save.py         |   2 +-
 swh/web/api/views/revision.py            |   2 +-
 swh/web/api/views/vault.py               |  10 +-
 swh/web/auth/views.py                    | 114 +++++-------
 swh/web/browse/browseurls.py             |   1 +
 swh/web/browse/identifiers.py            |   6 +-
 swh/web/browse/snapshot_context.py       | 303 ++++++++++++++-----------------
 swh/web/browse/views/content.py          |  98 +++++-----
 swh/web/browse/views/directory.py        |  77 ++++----
 swh/web/browse/views/origin.py           |  16 +-
 swh/web/browse/views/release.py          |  73 ++++----
 swh/web/browse/views/revision.py         | 225 +++++++++++------------
 swh/web/common/exc.py                    |  11 +-
 swh/web/common/middlewares.py            |  18 ++
 swh/web/settings/common.py               |   2 +
 swh/web/tests/api/test_apiresponse.py    |  40 ++--
 swh/web/tests/api/views/__init__.py      |   2 +-
 swh/web/tests/common/test_middlewares.py |  41 +++++
 22 files changed, 587 insertions(+), 585 deletions(-)
 create mode 100644 swh/web/tests/common/test_middlewares.py
Changes applied before test
commit 706829d86bfcaf2f7f6dfaf33a2bc071d928fa7e
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 18:04:04 2020 +0200

    browse: Improve error handling
    
    Use a dedicated django middleware to handle uncaught exception raised when
    processing a view and generate error response.
    
    Related to T2657

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/415/ for more details.

vlorentz accepted this revision.Thu, Oct 15, 8:01 PM
vlorentz added a subscriber: vlorentz.

lots of red lines :)

This revision is now accepted and ready to land.Thu, Oct 15, 8:01 PM

Build is green

Patch application report for D4277 (id=15125)

Could not rebase; Attempt merge onto d948e60ecd...

Updating d948e60e..1c043710
Fast-forward
 swh/web/api/apidoc.py                    |  24 +--
 swh/web/api/apiresponse.py               |  61 ++++---
 swh/web/api/apiurls.py                   |  44 +++--
 swh/web/api/views/content.py             |   2 +-
 swh/web/api/views/origin_save.py         |   2 +-
 swh/web/api/views/revision.py            |   2 +-
 swh/web/api/views/vault.py               |  10 +-
 swh/web/auth/views.py                    | 114 +++++-------
 swh/web/browse/browseurls.py             |   1 +
 swh/web/browse/identifiers.py            |   6 +-
 swh/web/browse/snapshot_context.py       | 303 ++++++++++++++-----------------
 swh/web/browse/views/content.py          |  98 +++++-----
 swh/web/browse/views/directory.py        |  77 ++++----
 swh/web/browse/views/origin.py           |  16 +-
 swh/web/browse/views/release.py          |  73 ++++----
 swh/web/browse/views/revision.py         | 225 +++++++++++------------
 swh/web/common/exc.py                    |  11 +-
 swh/web/common/middlewares.py            |  18 ++
 swh/web/settings/common.py               |   2 +
 swh/web/tests/api/test_apiresponse.py    |  40 ++--
 swh/web/tests/api/views/__init__.py      |   2 +-
 swh/web/tests/common/test_middlewares.py |  41 +++++
 22 files changed, 587 insertions(+), 585 deletions(-)
 create mode 100644 swh/web/tests/common/test_middlewares.py
Changes applied before test
commit 1c043710cbde5df2cbabef8a00b49f25c432a567
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 18:04:04 2020 +0200

    django: Improve error handling
    
    Use a dedicated django middleware to handle uncaught exception raised when
    processing a view and generate error response.
    
    Related to T2657

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/417/ for more details.

Build is green

Patch application report for D4277 (id=15129)

Could not rebase; Attempt merge onto d948e60ecd...

Updating d948e60e..11c2bbcc
Fast-forward
 swh/web/api/apidoc.py                    |  24 +--
 swh/web/api/apiresponse.py               |  61 ++++---
 swh/web/api/apiurls.py                   |  44 +++--
 swh/web/api/views/content.py             |   2 +-
 swh/web/api/views/origin_save.py         |   2 +-
 swh/web/api/views/revision.py            |   2 +-
 swh/web/api/views/vault.py               |  10 +-
 swh/web/auth/views.py                    | 114 +++++-------
 swh/web/browse/identifiers.py            |   6 +-
 swh/web/browse/snapshot_context.py       | 303 ++++++++++++++-----------------
 swh/web/browse/views/content.py          |  98 +++++-----
 swh/web/browse/views/directory.py        |  77 ++++----
 swh/web/browse/views/origin.py           |  16 +-
 swh/web/browse/views/release.py          |  73 ++++----
 swh/web/browse/views/revision.py         | 225 +++++++++++------------
 swh/web/common/exc.py                    |  11 +-
 swh/web/common/middlewares.py            |  18 ++
 swh/web/settings/common.py               |   2 +
 swh/web/tests/api/test_apiresponse.py    |  40 ++--
 swh/web/tests/api/views/__init__.py      |   2 +-
 swh/web/tests/common/test_middlewares.py |  41 +++++
 21 files changed, 586 insertions(+), 585 deletions(-)
 create mode 100644 swh/web/tests/common/test_middlewares.py
Changes applied before test
commit 11c2bbcc380b62dfe71630bece55f7c1bed76a40
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 18:04:04 2020 +0200

    django: Improve error handling
    
    Use a dedicated django middleware to handle uncaught exception raised when
    processing a view and generate error response.
    
    Related to T2657

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/420/ for more details.

Build is green

Patch application report for D4277 (id=15249)

Could not rebase; Attempt merge onto 7fbb185005...

Updating 7fbb1850..3add0d1e
Fast-forward
 swh/web/api/apidoc.py                    |  24 +--
 swh/web/api/apiresponse.py               |  61 ++++---
 swh/web/api/apiurls.py                   |  44 +++--
 swh/web/api/views/content.py             |   2 +-
 swh/web/api/views/origin_save.py         |   2 +-
 swh/web/api/views/revision.py            |   2 +-
 swh/web/api/views/vault.py               |  10 +-
 swh/web/auth/views.py                    | 114 +++++-------
 swh/web/browse/identifiers.py            |   6 +-
 swh/web/browse/snapshot_context.py       | 303 ++++++++++++++-----------------
 swh/web/browse/views/content.py          |  98 +++++-----
 swh/web/browse/views/directory.py        |  77 ++++----
 swh/web/browse/views/origin.py           |  16 +-
 swh/web/browse/views/release.py          |  73 ++++----
 swh/web/browse/views/revision.py         | 225 +++++++++++------------
 swh/web/common/exc.py                    |  11 +-
 swh/web/common/middlewares.py            |  18 ++
 swh/web/settings/common.py               |   2 +
 swh/web/tests/api/test_apiresponse.py    |  40 ++--
 swh/web/tests/api/views/__init__.py      |   2 +-
 swh/web/tests/common/test_middlewares.py |  41 +++++
 21 files changed, 586 insertions(+), 585 deletions(-)
 create mode 100644 swh/web/tests/common/test_middlewares.py
Changes applied before test
commit 3add0d1ee7ca0b2b4b7c428ebfcdd5ba7a6be397
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Wed Oct 7 18:04:04 2020 +0200

    django: Improve error handling
    
    Use a dedicated django middleware to handle uncaught exception raised when
    processing a view and generate error response.
    
    Related to T2657

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/423/ for more details.

This revision was automatically updated to reflect the committed changes.