Added API tests
[mediagoblin.git] / mediagoblin / errormiddleware.py
... / ...
CommitLineData
1# GNU MediaGoblin -- federated, autonomous media hosting
2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from paste.exceptions.errormiddleware import make_error_middleware
18
19MGOBLIN_ERROR_MESSAGE = """\
20<div style="text-align:center;font-family: monospace">
21 <h1>YEOWCH... that's an error!</h1>
22 <pre>
23.-------------------------.
24| __ _ |
25| -, \_,------,_// |
26| <\ ,-- --.\ |
27| / (x ) ( X ) |
28| ' '--, ,--'\ |
29| / \ -v-v-u-v / |
30| . '.__.--__'.\ |
31| / ',___/ / \__/' |
32| | | ,'\_'/, || |
33| \_| | | | | || |
34| W',_ ||| |||_'' |
35| | '------'| |
36| |__| |_|_ |
37| ,,,-' '-,,, |
38'-------------------------'
39 </pre>
40 <p>Something bad happened, and things broke.</p>
41 <p>If this is not your website, you may want to alert the owner.</p>
42 <br><br>
43 <p>
44 Powered... er broken... by
45 <a href="http://www.mediagoblin.org">MediaGoblin</a>,
46 a <a href="http://www.gnu.org">GNU Project</a>.
47 </p>
48</div>"""
49
50
51def mgoblin_error_middleware(app, global_conf, **kw):
52 """
53 MediaGoblin wrapped error middleware.
54
55 This is really just wrapping the error middleware from Paste.
56 It should take all of Paste's default options, so see:
57 http://pythonpaste.org/modules/exceptions.html
58 """
59 kw['error_message'] = MGOBLIN_ERROR_MESSAGE
60 return make_error_middleware(app, global_conf, **kw)