aboutsummaryrefslogtreecommitdiffstats
path: root/pysite
diff options
context:
space:
mode:
Diffstat (limited to 'pysite')
-rw-r--r--pysite/views/error_handlers/http_4xx.py13
-rw-r--r--pysite/views/error_handlers/http_5xx.py15
2 files changed, 26 insertions, 2 deletions
diff --git a/pysite/views/error_handlers/http_4xx.py b/pysite/views/error_handlers/http_4xx.py
index 5874b862..5717feae 100644
--- a/pysite/views/error_handlers/http_4xx.py
+++ b/pysite/views/error_handlers/http_4xx.py
@@ -1,6 +1,6 @@
# coding=utf-8
from flask import render_template, request
-from werkzeug.exceptions import NotFound
+from werkzeug.exceptions import HTTPException
from pysite.base_route import ErrorView
from pysite.constants import ERROR_DESCRIPTIONS
@@ -10,7 +10,16 @@ class Error400View(ErrorView):
name = "error_4xx"
error_code = range(400, 430)
- def get(self, error: NotFound):
+ def get(self, error: HTTPException):
+ error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.")
+
+ return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc,
+ error_message=error_desc +
+ " If you believe we have made a mistake, please "
+ "<a href='https://github.com"
+ "/discord-python/site/issues'>open an issue on our GitHub</a>."), error.code
+
+ def post(self, error: HTTPException):
error_desc = ERROR_DESCRIPTIONS.get(error.code, "We're not really sure what happened there, please try again.")
return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc,
diff --git a/pysite/views/error_handlers/http_5xx.py b/pysite/views/error_handlers/http_5xx.py
index 410be265..6bbc8275 100644
--- a/pysite/views/error_handlers/http_5xx.py
+++ b/pysite/views/error_handlers/http_5xx.py
@@ -23,3 +23,18 @@ class Error500View(ErrorView):
"<a href='https://github.com"
"/discord-python/site/issues'>file an issue on our GitHub"
"</a>."), error.code
+
+ def post(self, error: HTTPException):
+ error_desc = ERROR_DESCRIPTIONS.get(error.code,
+ "We're not really sure what happened there, please try again.")
+
+ return render_template("errors/error.html", code=error.code, req=request, error_title=error_desc,
+ error_message="An error occurred while "
+ "processing this "
+ "request, please try "
+ "again later. "
+ "If you believe we have made a mistake, "
+ "please "
+ "<a href='https://github.com"
+ "/discord-python/site/issues'>file an issue on our GitHub"
+ "</a>."), error.code