1
0
mirror of https://github.com/djohnlewis/stackdump synced 2024-12-04 23:17:37 +00:00

Added an error page for when Stackdump fails to connect to Solr.

Also unified the error pages and added a generic 500 error page.
This commit is contained in:
Samuel Lai 2012-08-19 00:09:35 +10:00
parent e0c96a5c5f
commit 1b27784a8c
5 changed files with 64 additions and 5 deletions

View File

@ -365,12 +365,12 @@ h1.answers {
float: right;
}
.nodata.row, .importinprogress.row {
.nodata.row, .importinprogress.row, .errormessage.row {
margin-top: 50px;
margin-bottom: 20px;
}
.nodata h2, .importinprogress h2 {
.nodata h2, .importinprogress h2, .errormessage h2 {
margin-top: 25px;
margin-bottom: 7px;
}
@ -392,6 +392,6 @@ h1.answers {
margin-top: 7px;
}
.importinprogress .subinfo {
.importinprogress .subinfo, .errormessage .subinfo {
color: #999999;
}

View File

@ -6,6 +6,7 @@ import re
import math
import random
import urllib2
import socket
from xml.etree import ElementTree
try:
@ -244,8 +245,19 @@ def error500(error):
# HACK: the exception object doesn't seem to provide a better way though.
if 'database is locked' in ex.args:
return render_template('importinprogress.html')
if isinstance(ex, socket.error):
# if the error is connection refused, then it is likely because Solr is
# not running. Show a nice error message.
if ex.errno == 111:
return render_template('solrnotrunning.html')
# otherwise, return the standard error message
if not settings.DEBUG:
try:
return render_template('500.html')
except: # if there are any errors, just render Bottle's default error page.
pass
return repr(error)
@get('/')

View File

@ -1,11 +1,11 @@
{% extends 'base.html' %}
{% block title %}
Stackdump - Error 404: Not Found
Stackdump // Error 404: Not Found
{% endblock %}
{% block body %}
<div class="row nodata">
<div class="row errormessage">
<div class="span16">
<h1>Error 404: Not Found</h1>
<p>

View File

@ -0,0 +1,23 @@
{% extends 'base.html' %}
{% block title %}
Stackdump // Error 500: {{ error.output }}
{% endblock %}
{% block body %}
<div class="row errormessage">
<div class="span16">
<h1>Something went wrong.</h1>
<p>
Stackdump could not complete your request. Try your query again
later as this may be a symptom of a high load on the app at the
moment.
</p>
<p class="subinfo">
If this issue persists, try restarting the Stackdump daemons/
services (<em>stackdump_web</em> and/or <em>stackdump_solr</em>)
or processes (<em>start_web.sh</em> and/or <em>start_solr.sh</em>).
</p>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,24 @@
{% extends 'base.html' %}
{% block title %}
Stackdump // cannot connect to the search index
{% endblock %}
{% block body %}
<div class="row errormessage">
<div class="span16">
<h1>Stackdump cannot connect to the search index.</h1>
<p>
This may be due to a temporary issue (e.g. due to high load).
Try your query again later.
</p>
<p class="subinfo">
If this issue does not resolve itself in a few minutes, check
that the <em>stackdump_solr</em> daemon/service or
<em>start_solr.sh</em> process is running.
</p>
</div>
</div>
{% endblock %}