Skip to content
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

better internalerror page #10414

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 8 additions & 4 deletions openlibrary/i18n/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,22 @@ msgid "Internal Error"
msgstr ""

#: internalerror.html
msgid "Hmm..."
msgid "A Problem Occurred"
msgstr ""

#: internalerror.html
msgid "Sorry. There seems to be a problem with what you were just looking at."
msgid "We're sorry, a problem occurred while responding to your request:"
msgstr ""

#: internalerror.html
#, python-format
msgid ""
"We've noted the error %s and will look into it as soon as possible. Head "
"for <a href=\"/\">home</a>?"
"The reference code %s has been created to track this error and we will "
"investigate as we're able."
msgstr ""

#: internalerror.html
msgid "Return to the <a href=\"javascript:history.back()\">previous page</a>?"
msgstr ""

#: lib/nav_head.html library_explorer.html
Expand Down
8 changes: 7 additions & 1 deletion openlibrary/plugins/openlibrary/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,10 @@ def save_error():
def internalerror():
name = save_error()

import sys

exception_type, exception_value, _ = sys.exc_info()

# TODO: move this stats stuff to plugins\openlibrary\stats.py
# Can't have sub-metrics, so can't add more info
openlibrary.core.stats.increment('ol.internal-errors')
Expand All @@ -1139,7 +1143,9 @@ def internalerror():
if features.is_enabled('debug'):
raise web.debugerror()
else:
msg = render.site(render.internalerror(name))
msg = render.site(
render.internalerror(name, etype=exception_type, evalue=exception_value)
)
raise web.internalerror(web.safestr(msg))


Expand Down
14 changes: 9 additions & 5 deletions openlibrary/templates/internalerror.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
$def with (name)
$def with (name, etype=None, evalue=None)

$var title: $_("Internal Error")

<div id="contentHead">
<h1>$_("Hmm...")</h1>
<h1>$_("A Problem Occurred")</h1>
</div>

<div id="contentBody">
<p>$_("Sorry. There seems to be a problem with what you were just looking at.")</p>
<p>$:_('We\'ve noted the error %s and will look into it as soon as possible. Head for <a href="/">home</a>?', name)</p>

<p>$_("We're sorry, a problem occurred while responding to your request:")</p>
<code>
$etype
$evalue
</code>
<p>$:_("The reference code %s has been created to track this error and we will investigate as we're able.", name)</p>
<p>$:_('Return to the <a href="javascript:history.back()">previous page</a>?')</p>
</div>
Loading