aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-12-20 20:21:29 -0800
committerJames Taylor <user234683@users.noreply.github.com>2019-12-20 20:21:29 -0800
commit98fbdf77cb7af6d49bbd981765ac84824fe114c2 (patch)
treec21f74269919a5603fac2a43bf06d6c9d645dbba /youtube
parent80de90b1bbccdfc8bc3f8f48b8059125f14f0945 (diff)
downloadyt-local-98fbdf77cb7af6d49bbd981765ac84824fe114c2.tar.lz
yt-local-98fbdf77cb7af6d49bbd981765ac84824fe114c2.tar.xz
yt-local-98fbdf77cb7af6d49bbd981765ac84824fe114c2.zip
Add custom 500 error page. Display the traceback. Center and format error page in general.
Also add a link to github for reporting the exception.
Diffstat (limited to 'youtube')
-rw-r--r--youtube/__init__.py5
-rw-r--r--youtube/templates/error.html35
2 files changed, 39 insertions, 1 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py
index 534b9f8..d8171c0 100644
--- a/youtube/__init__.py
+++ b/youtube/__init__.py
@@ -1,5 +1,6 @@
import flask
import settings
+import traceback
yt_app = flask.Flask(__name__)
yt_app.url_map.strict_slashes = False
@@ -30,3 +31,7 @@ def commatize(num):
if isinstance(num, str):
num = int(num)
return '{:,}'.format(num)
+
+@yt_app.errorhandler(500)
+def error_page(e):
+ return flask.render_template('error.html', traceback=traceback.format_exc()), 500
diff --git a/youtube/templates/error.html b/youtube/templates/error.html
index e77c92c..27b68ff 100644
--- a/youtube/templates/error.html
+++ b/youtube/templates/error.html
@@ -1,7 +1,40 @@
{% set page_title = 'Error' %}
{% extends "base.html" %}
+{% block style %}
+ h1{
+ font-size: 32px;
+ font-weight: normal;
+ }
+ #error-box, #error-message{
+ background-color: var(--interface-color);
+ width: 80%;
+ margin: auto;
+ margin-top: 20px;
+ padding: 5px;
+ }
+ #error-box > div, #error-box > p, #error-box > h1{
+ white-space: pre-wrap;
+ margin-bottom: 10px;
+ }
+ .code-box{
+ padding: 5px;
+ border-style:solid;
+ border-width:1px;
+ border-radius:5px;
+ }
+{% endblock style %}
+
{% block main %}
- {{ error_message }}
+ {% if traceback %}
+ <div id="error-box">
+ <h1>500 Uncaught exception:</h1>
+ <div class="code-box"><code>{{ traceback }}</code></div>
+ <p>Please report this issue at <a href="https://github.com/user234683/youtube-local/issues" target="_blank">https://github.com/user234683/youtube-local/issues</a></p>
+ <p>Remember to include the traceback in your issue and redact any information in it you do not want to share</p>
+ </div>
+ {% else %}
+ <div id="error-message">{{ error_message }}</div>
+ {% endif %}
{% endblock %}