mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-26 01:04:00 -04:00
Add error handling
This adds an /error/XXX endpoint that triggers the corresponding XXX error code and its handling. Related: https://github.com/alphagov/notifications-aws/pull/331
This commit is contained in:
@@ -488,6 +488,10 @@ def register_errorhandlers(application): # noqa (C901 too complex)
|
|||||||
def handle_gone(error):
|
def handle_gone(error):
|
||||||
return _error_response(410)
|
return _error_response(410)
|
||||||
|
|
||||||
|
@application.errorhandler(413)
|
||||||
|
def handle_payload_too_large(error):
|
||||||
|
return _error_response(413)
|
||||||
|
|
||||||
@application.errorhandler(404)
|
@application.errorhandler(404)
|
||||||
def handle_not_found(error):
|
def handle_not_found(error):
|
||||||
return _error_response(404)
|
return _error_response(404)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from flask import redirect, render_template, request, url_for
|
from flask import redirect, render_template, request, url_for, abort
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
from notifications_utils.international_billing_rates import (
|
from notifications_utils.international_billing_rates import (
|
||||||
INTERNATIONAL_BILLING_RATES,
|
INTERNATIONAL_BILLING_RATES,
|
||||||
@@ -18,6 +18,11 @@ def index():
|
|||||||
return render_template('views/signedout.html')
|
return render_template('views/signedout.html')
|
||||||
|
|
||||||
|
|
||||||
|
@main.route('/error/<int:status_code>')
|
||||||
|
def error(status_code):
|
||||||
|
abort(status_code)
|
||||||
|
|
||||||
|
|
||||||
@main.route("/verify-mobile")
|
@main.route("/verify-mobile")
|
||||||
@login_required
|
@login_required
|
||||||
def verify_mobile():
|
def verify_mobile():
|
||||||
|
|||||||
21
app/templates/error/413.html
Normal file
21
app/templates/error/413.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{% extends "withoutnav_template.html" %}
|
||||||
|
{% block per_page_title %}File too big{% endblock %}
|
||||||
|
{% block maincolumn_content %}
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="column-two-thirds">
|
||||||
|
<h1 class="heading-large">
|
||||||
|
The file you uploaded was too big
|
||||||
|
</h1>
|
||||||
|
<div class="grid-row">
|
||||||
|
<div class="column-two-thirds">
|
||||||
|
<p>
|
||||||
|
Files must be smaller than 5 MB.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<a href="javascript: history.go(-1)">Go back and try again.</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user