Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
ADD: More beautiful error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
claussmann committed Jan 29, 2024
1 parent 2f78570 commit ddd342e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyteamquiz/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def new_game():
teams = set(filter(len, request.form.getlist('teams[]')))
try:
game_id = service.new_game(selected, teams)
except (NotEnoughQuestionsError, NotEnoughTeamsError) as e:
return "<h1>ERROR: %s</h1>" % str(e)
except (NotEnoughQuestionsError, NotEnoughTeamsError, TeamNameError) as e:
return render_template('error.html', msg=str(e))
return render_template('created.html', game_id=game_id)

@app.route("/<game_id>/question", methods=["GET"])
Expand Down
10 changes: 10 additions & 0 deletions pyteamquiz/templates/error.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% extends "base.html" %}
{% block content %}

<h1>Sorry, there was an error.</h1>

<p>
The error message is: <b>{{ msg }}</b>
</p>

{% endblock %}

0 comments on commit ddd342e

Please sign in to comment.