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:
Athanasios Voutsadakis
2018-03-08 17:49:08 +00:00
parent 57a77318c9
commit 249ae41c24
3 changed files with 31 additions and 1 deletions

View File

@@ -488,6 +488,10 @@ def register_errorhandlers(application): # noqa (C901 too complex)
def handle_gone(error):
return _error_response(410)
@application.errorhandler(413)
def handle_payload_too_large(error):
return _error_response(413)
@application.errorhandler(404)
def handle_not_found(error):
return _error_response(404)

View File

@@ -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 notifications_utils.international_billing_rates import (
INTERNATIONAL_BILLING_RATES,
@@ -18,6 +18,11 @@ def index():
return render_template('views/signedout.html')
@main.route('/error/<int:status_code>')
def error(status_code):
abort(status_code)
@main.route("/verify-mobile")
@login_required
def verify_mobile():

View 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 %}