Skip to content

Commit

Permalink
Only show traceback if in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
vangheem committed Aug 7, 2017
1 parent 1e6153d commit 369d827
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
@@ -1,7 +1,8 @@
1.3.1 (unreleased)
------------------

- Nothing changed yet.
- Only show traceback if in debug mode
[vangheem]


1.3.0 (2017-08-01)
Expand Down
9 changes: 9 additions & 0 deletions README.rst
Expand Up @@ -97,3 +97,12 @@ Default
-------

Default root access can be done with AUTHORIZATION header : Basic root:root



TODO
----

- be able to configure renderer from function view configuration
- view functions can take 2, 1 or zero args
- handle routes in definitions...
1 change: 1 addition & 0 deletions guillotina/__init__.py
Expand Up @@ -14,6 +14,7 @@


app_settings = {
"debug": False,
"aiohttp_settings": {},
"databases": [],
"conflict_retry_attempts": 3,
Expand Down
10 changes: 6 additions & 4 deletions guillotina/traversal.py
Expand Up @@ -322,13 +322,15 @@ async def real_resolve(self, request):
except Exception as _exc:
request.resource = request.tail = None
request.exc = _exc
# XXX should only should traceback if in some sort of dev mode?
raise HTTPBadRequest(text=json.dumps({
data = {
'success': False,
'exception_message': str(_exc),
'exception_type': getattr(type(_exc), '__name__', str(type(_exc))), # noqa
'traceback': traceback.format_exc()
}))
}
if app_settings.get('debug'):
data['traceback'] = traceback.format_exc()
# XXX should only should traceback if in some sort of dev mode?
raise HTTPBadRequest(text=json.dumps(data))

request.resource = resource
request.tail = tail
Expand Down

0 comments on commit 369d827

Please sign in to comment.