vigiboard / vigiboard / controllers / error.py @ 5f2cd70a
History | View | Annotate | Download (1.01 KB)
1 |
# -*- coding: utf-8 -*-
|
---|---|
2 |
"""Error controller"""
|
3 |
|
4 |
from tg import request, expose |
5 |
|
6 |
__all__ = ['ErrorController']
|
7 |
|
8 |
|
9 |
class ErrorController(object): |
10 |
"""
|
11 |
Generates error documents as and when they are required.
|
12 |
|
13 |
The ErrorDocuments middleware forwards to ErrorController when error
|
14 |
related status codes are returned from the application.
|
15 |
|
16 |
This behaviour can be altered by changing the parameters to the
|
17 |
ErrorDocuments middleware in your config/middleware.py file.
|
18 |
|
19 |
"""
|
20 |
|
21 |
@expose('error.html') |
22 |
def document(self, *args, **kwargs): |
23 |
"""Render the error document"""
|
24 |
resp = request.environ.get('pylons.original_response')
|
25 |
default_message = ("<p>We're sorry but we weren't able to process "
|
26 |
" this request.</p>")
|
27 |
values = dict(prefix=request.environ.get('SCRIPT_NAME', ''), |
28 |
code=request.params.get('code', resp.status_int),
|
29 |
message=request.params.get('message', default_message))
|
30 |
return values
|