Skip to content

Custom Error Pages #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/scss/components/code.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pre{
white-space: pre-wrap;
}
1 change: 1 addition & 0 deletions frontend/scss/packet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ $csh-pink: #b0197e;
@import "components/buttons";
@import "components/signatures";
@import "components/badges";
@import "components/code";
14 changes: 14 additions & 0 deletions packet/routes/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ def service_worker():
@app.route('/OneSignalSDKUpdaterWorker.js', methods=['GET'])
def update_service_worker():
return app.send_static_file('js/update-sw.js')


@app.errorhandler(404)
@packet_auth
@before_request
def not_found(e, info=None):
return render_template('not_found.html', e=e, info=info), 404


@app.errorhandler(500)
@packet_auth
@before_request
def error(e, info=None):
return render_template('error.html', e=e, info=info), 500
20 changes: 20 additions & 0 deletions packet/templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends 'extend/base.html' %}

{% block body %}
<div class="container main">
<h1 class="card-title">Oops!</h1>
<div class="card mb-3">
<div class="card-body" style="text-align: left;">
<h5 class="card-text">
I guess this is what you get when you trust a bunch of college kids.
</h5>
<p class="card-text">
<pre><code>{{ e }}</code></pre>
</p>
<h5 class="card-text">
Do us a favor, try again. If you end up here on the second try, <a href="mailto:[email protected]">shoot us an email</a>.
</h5>
</div>
</div>
</div>
{% endblock %}
17 changes: 17 additions & 0 deletions packet/templates/not_found.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'extend/base.html' %}

{% block body %}
<div class="container main">
<h1 class="card-title">Page Not Found</h1>
<div class="card mb-3">
<div class="card-body" style="text-align: left;">
<h4 class="card-text">
Not sure what you're looking for, but it's not here.
</h4>
<h5 class="card-text">
Do us a favor, check your spelling. If you can't find what you're looking for, <a href="mailto:[email protected]">shoot us an email</a>.
</h5>
</div>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ gunicorn~=19.7.1
csh_ldap~=2.1.0
onesignal-sdk~=1.0.0
pylint-quotes~=0.2.1
sentry-sdk==0.13.1
sentry-sdk~=0.14.2