~edwargix/git.sr.ht

e4521bf84695542f9dcaf344361ad54395db0cfd — Drew DeVault 8 years ago f4328ee
Move error handling to shared code
2 files changed, 0 insertions(+), 28 deletions(-)

M git/app.py
D templates/not_found.html
M git/app.py => git/app.py +0 -18
@@ 22,21 22,3 @@ except:
from git.blueprints.cgit import cgit

app.register_blueprint(cgit)

if not app.debug:
    @app.errorhandler(500)
    def handle_500(e):
        # shit
        try:
            db.rollback()
            db.close()
        except:
            # shit shit
            sys.exit(1)
        return render_template("internal_error.html"), 500

@app.errorhandler(404)
def handle_404(e):
    if request.path.startswith("/api"):
        return { "errors": [ { "reason": "404 not found" } ] }, 404
    return render_template("not_found.html"), 404

D templates/not_found.html => templates/not_found.html +0 -10
@@ 1,10 0,0 @@
{% extends "layout.html" %}
{% block body %} 
<div class="container">
  <h2>404 Not Found</h2>
  <p>
  Whatever you're looking for, it isn't here.
  <a href="/">Index <i class="fa fa-caret-right"></i></a>
  </p>
</div>
{% endblock %}