forked from MarseyWorld/MarseyWorld
handle 500 and 401 (when using API) with our handlers
* 401 had sign up and login buttons on their page, but the page was never visible, we only show this when the API is being usedmaster
parent
e364ce8043
commit
665e6e4b21
|
@ -53,6 +53,10 @@ ERROR_MSGS = {
|
|||
500: "Hiiiii it's carp! I think this error means that there's a timeout error. And I think that means something took too long to load so it decided not to work at all. If you keep seeing this on the same page <I>but not other pages</I>, then something is probably wrong with that specific function. It may not be called a function, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3",
|
||||
}
|
||||
|
||||
ERROR_MSGS_PCM = {
|
||||
500: "Hiiiii it's <b>nigger</b>! I think this error means that there's a <b>nigger</b> error. And I think that means something took too long to load so it decided to be a <b>nigger</b>. If you keep seeing this on the same page but not other pages, then something its probably a <b>niggerfaggot</b>. It may not be called a <b>nigger</b>, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3"
|
||||
}
|
||||
|
||||
ERROR_MARSEYS = {
|
||||
400: "marseybrainlet",
|
||||
401: "marseydead",
|
||||
|
@ -88,11 +92,14 @@ def error(e):
|
|||
if request.headers.get("Authorization") or request.headers.get("xhr"):
|
||||
return {"error": title, "code": e.code, "description": msg, "details": details}
|
||||
img = ERROR_MARSEYS.get(e.code, 'marseyl')
|
||||
if e.code == 500 and SITE_NAME == 'PCM':
|
||||
msg = ERROR_MSGS_PCM.get(e.code, str(e.code))
|
||||
img = "wholesome"
|
||||
return render_template('errors/error.html', err=True, title=title, msg=msg, details=details, img=img), e.code
|
||||
|
||||
@app.errorhandler(401)
|
||||
def error_401(e):
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "401 Unauthorized"}, 401
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return error(e)
|
||||
else:
|
||||
path = request.path
|
||||
qs = urlencode(dict(request.values))
|
||||
|
@ -104,8 +111,7 @@ def error_401(e):
|
|||
@app.errorhandler(500)
|
||||
def error_500(e):
|
||||
g.db.rollback()
|
||||
if request.headers.get("Authorization") or request.headers.get("xhr"): return {"error": "500 Internal Server Error"}, 500
|
||||
else: return render_template('errors/500.html', err=True), 500
|
||||
return error(e)
|
||||
|
||||
|
||||
@app.post("/allow_nsfw")
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>401 Not Authorized</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}error-401{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-10 col-md-5">
|
||||
<div class="text-center px-3 my-8">
|
||||
|
||||
<img alt=":#marseydead:" loading="lazy" src="/e/marseydead.webp">
|
||||
<pre></pre>
|
||||
|
||||
<h1 class="h5">401 Not Authorized</h1>
|
||||
<p class="text-muted mb-5">What you're trying to do requires an account. I think. The original error message said something about a castle and I hated that.</p>
|
||||
<div><a href="/signup" class="btn btn-primary mb-2">Create an account</a></div>
|
||||
<div><a href="/login" class="text-muted text-small">Or sign in</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,31 +0,0 @@
|
|||
{% extends "default.html" %}
|
||||
|
||||
{% block title %}
|
||||
<title>500 Internal Server Error</title>
|
||||
{% endblock %}
|
||||
|
||||
{% block pagetype %}error-500{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-10 col-md-5">
|
||||
<div class="text-center px-3 my-8">
|
||||
{% if SITE_NAME == 'PCM' %}
|
||||
<img alt="wholesome" loading="lazy" src="/i/wholesome.webp">
|
||||
{% else %}
|
||||
<img alt=":#marseycarp3:" loading="lazy" src="/e/marseycarp3.webp">
|
||||
{% endif %}
|
||||
<pre></pre>
|
||||
<h1 class="h5">500 Internal Server Error</h1>
|
||||
<p class="text-muted mb-5">
|
||||
{% if SITE_NAME == 'PCM' %}
|
||||
Hiiiii it's <b>nigger</b>! I think this error means that there's a <b>nigger</b> error. And I think that means something took too long to load so it decided to be a <b>nigger</b>. If you keep seeing this on the same page but not other pages, then something its probably a <b>niggerfaggot</b>. It may not be called a <b>nigger</b>, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3
|
||||
{% else %}
|
||||
Hiiiii it's carp! I think this error means that there's a timeout error. And I think that means something took too long to load so it decided not to work at all. If you keep seeing this on the same page <I>but not other pages</I>, then something is probably wrong with that specific function. It may not be called a function, but that sounds right to me. Anyway, ping me and I'll whine to someone smarter to fix it. Don't bother them. Thanks ily <3
|
||||
{% endif %}
|
||||
</p>
|
||||
<div><a href="/" class="btn btn-primary">Go to the frontpage</a></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue