Merge ~andersson123/autopkgtest-cloud:custom_server_error_message into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Merged
Approved by: Tim Andersson
Approved revision: 932646663e903ad2ac9c0f14d105f8451cd90df3
Merged at revision: e67980dd111fa1bf9e0fbaad18a65a24562b73d2
Proposed branch: ~andersson123/autopkgtest-cloud:custom_server_error_message
Merge into: autopkgtest-cloud:master
Diff against target: 28 lines (+20/-0)
1 file modified
charms/focal/autopkgtest-web/webcontrol/request/app.py (+20/-0)
Reviewer Review Type Date Requested Status
Paride Legovini Approve
Review via email: mp+449934@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

irc.libera.chat

Revision history for this message
Paride Legovini (paride) wrote :

Inline questions.

review: Needs Information
Revision history for this message
Paride Legovini (paride) :
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

I've made amendments based on your comments and I'm going to test it in staging now.

Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Tim Andersson (andersson123) wrote :

Hm. It's not working now for some reason.

Revision history for this message
Tim Andersson (andersson123) wrote :

I'm going to repack the charm from the previous commit and test it again.

Revision history for this message
Tim Andersson (andersson123) wrote :

Really weird. I reverted to prior commit, it worked, and i hotfixed the code back in and it worked. Strange. I'll clean up the MP and consider it ready for review

Revision history for this message
Tim Andersson (andersson123) wrote :

Let's hold on this, it seems that this change means that the traceback no longer goes to error.log, I'll make an amendment.

Revision history for this message
Tim Andersson (andersson123) wrote :

Amended and rebased.

Revision history for this message
Paride Legovini (paride) wrote :

One nit, otherwise LGTM/

review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) wrote :

:facepalm:

Revision history for this message
Paride Legovini (paride) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py
2index 5f47be2..55631f0 100644
3--- a/charms/focal/autopkgtest-web/webcontrol/request/app.py
4+++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py
5@@ -299,3 +299,23 @@ def logout():
6 """Clear user session, logging them out."""
7 session.clear()
8 return redirect(oid.get_next_url())
9+
10+
11+@app.errorhandler(Exception)
12+def all_exception_handler(error):
13+ # If the exception doesn't have the exit_code method, it's not an expected
14+ # exception defined in helpers/exceptions.py
15+ try:
16+ return invalid(error, error.exit_code())
17+ except Exception:
18+ return (
19+ HTML.format(
20+ (
21+ "<p>A server error has occured, please contact a member of the Ubuntu QA team. "
22+ + "You can contact them via the ubuntu-quality mailing list, "
23+ + "or via the #ubuntu-quality IRC channel on irc.libera.chat. Traceback: %s</p>"
24+ % str(error)
25+ ),
26+ ),
27+ 500,
28+ )

Subscribers

People subscribed via source and target branches