Skip to content

Instantly share code, notes, and snippets.

@moschlar
Last active December 17, 2015 00:49
Show Gist options
  • Save moschlar/5523905 to your computer and use it in GitHub Desktop.
Save moschlar/5523905 to your computer and use it in GitHub Desktop.
def add_error_middleware(self, global_conf, app):
"""Add middleware which handles errors and exceptions."""
from pylons.middleware import report_libs, StatusCodeRedirect
from tg.error import ErrorHandler
#from raven import Client
#from raven.middleware import Sentry as WSGISentry
#app = WSGISentry(app, Client(config.get('sentry.dsn')))
from raven.contrib.pylons import Sentry as PylonsSentry
app = PylonsSentry(app, config)
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
# Display error documents for self.handle_status_codes status codes (and
# 500 when debug is disabled)
from paste.deploy.converters import asbool
if asbool(config['debug']):
app = StatusCodeRedirect(app, self.handle_status_codes)
else:
app = StatusCodeRedirect(app, self.handle_status_codes + [500])
return app
{"id": "aecb2e19977f4677be23fb0ff0c92c8b", "checksum": "ab84d6e5a9616f0ee515d588300bfd20", "project": "sauce", "logger": "sauce.controllers.error", "level": "info", "culprit": "sauce.controllers.error in document", "extra": {"thread": 140225918248704, "process": 29397, "sys.argv": ["'mod_wsgi'"], "threadName": "'MainThread'", "filename": "'error.py'", "processName": "'MainProcess'", "pathname": "'/opt/wsgi/SAUCE/1.3dev/sauce/controllers/error.py'", "lineno": 71, "asctime": "'2013-05-06 09:58:55'", "message": "'Error 500 Internal Server Error, Request: GET https://sauce.zdv.uni-mainz.de:8888/debug/exception, Referer: None'"}, "modules": {}, "sentry.interfaces.Message": {"message": "Error %s, Request: %s %s, Referer: %s", "params": ["'500 Internal Server Error'", "'GET'", "'https://sauce.zdv.uni-mainz.de:8888/debug/exception'", null]}, "tags": []}
[sentry]
dsn=http://<keys>@sentry.<host>/2
#include_paths=sauce,tg,sqlalchemy,tw2,pylons,webob,raven.contrib.django,raven.middleware,
#exclude_paths=
URL: https://sauce.zdv.uni-mainz.de:8888/debug/exception
Module weberror.errormiddleware:242 in next
>> return self.app_iterator.next()
Module raven.middleware:30 in __call__
>> iterable = self.application(environ, start_response)
Module tg.configuration.app_config:945 in remover
>> return app(environ, start_response)
Module repoze.tm:24 in __call__
>> result = self.application(environ, save_status_and_headers)
Module repoze.who.middleware:107 in __call__
>> app_iter = app(environ, wrapper.wrap_start_response)
Module tw2.core.middleware:195 in __call__
>> resp = req.get_response(self.app, catch_exc_info=True)
Module webob.request:1082 in get_response
>> application, catch_exc_info=True)
Module webob.request:1055 in call_application
>> app_iter = application(self.environ, start_response)
Module beaker.middleware:73 in __call__
>> return self.app(environ, start_response)
Module sauce.config.app_cfg:78 in __call__
>> return self.app(environ, start_response)
Module routes.middleware:131 in __call__
>> response = self.app(environ, start_response)
Module pylons.wsgiapp:107 in __call__
>> response = self.dispatch(controller, environ, start_response)
Module pylons.wsgiapp:312 in dispatch
>> return controller(environ, start_response)
Module sauce.lib.base:111 in __call__
>> return super(BaseController, self).__call__(environ, start_response)
Module pylons.controllers.core:211 in __call__
>> response = self._dispatch_call()
Module pylons.controllers.core:162 in _dispatch_call
>> response = self._inspect_call(func)
Module pylons.controllers.core:105 in _inspect_call
>> result = self._perform_call(func, args)
Module tg.controllers.dispatcher:124 in _perform_call
>> r = self._call(func, params, remainder=remainder)
Module tg.controllers.decoratedcontroller:133 in _call
>> output = controller_callable(*remainder, **dict(params))
Module sauce.controllers.debug:63 in exception
>> raise DebugException()
CGI Variables
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment