diff options
author | John Vrbanac <john.vrbanac@rackspace.com> | 2015-06-01 18:24:22 -0500 |
---|---|---|
committer | John Vrbanac <john.vrbanac@rackspace.com> | 2015-06-03 19:12:53 -0500 |
commit | d3159f1d6bec06845b152de836793f4454d95804 (patch) | |
tree | 39b6776ad87cd3014daae890ce5e8f3cc589001e /pecan/tests | |
parent | 17d5357003f65249aebbf6ee08bf38cc6bf40b63 (diff) | |
download | pecan-d3159f1d6bec06845b152de836793f4454d95804.tar.gz |
Allowing tracebacks to be surfaced through abort
Currently, anytime abort(...) is called, It raises a new
exception which then suppresses any existing tracebacks.
This causes error monitoring systems like NewRelic to
report back worthless surface-level tracebacks that have
nothing to do with the application.
This change allows for the exception type to change, but
keep the existing traceback (if one exists). This allows
for monitoring systems to see a real traceback that can
be correlated to logged information.
Change-Id: Ibe6eb37e25b74d1dcfca76dfc1f5bbce28d34e85
Diffstat (limited to 'pecan/tests')
-rw-r--r-- | pecan/tests/test_base.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py index e6adf0e..785b522 100644 --- a/pecan/tests/test_base.py +++ b/pecan/tests/test_base.py @@ -3,6 +3,7 @@ import sys import os import json +import traceback import warnings import webob @@ -1121,6 +1122,20 @@ class TestAbort(PecanTestCase): r = app.get('/', status=401) assert r.status_int == 401 + def test_abort_keeps_traceback(self): + last_exc, last_traceback = None, None + + try: + try: + raise Exception('Bottom Exception') + except: + abort(404) + except Exception: + last_exc, _, last_traceback = sys.exc_info() + + assert last_exc is HTTPNotFound + assert 'Bottom Exception' in traceback.format_tb(last_traceback)[-1] + class TestScriptName(PecanTestCase): |