Skip to content
Browse files

Merge pull request #65 from hellais/error-traceback

Implement stack trace printing for exceptions when in debug mode
  • Loading branch information...
2 parents ee039f0 + 80a4bfe commit 8ef89c3b7c4da774d76c3b521343ed7f23af4889 @fiorix committed Aug 29, 2012
Showing with 11 additions and 1 deletion.
  1. +11 −1 cyclone/web.py
View
12 cyclone/web.py
@@ -1312,7 +1312,17 @@ def __call__(self, request):
for spec in handlers:
match = spec.regex.match(request.path)
if match:
- handler = spec.handler_class(self, request, **spec.kwargs)
+ # If we are in debug mode
+ #
+ if self.settings.get("debug"):
+ try:
+ handler = spec.handler_class(self, request, **spec.kwargs)
+ except:
+ traceback.print_exc()
+ handler = ErrorHandler(self, request, status_code=500)
+ else:
+ handler = spec.handler_class(self, request, **spec.kwargs)
+
if spec.regex.groups:
# None-safe wrapper around url_unescape to handle
# unmatched optional groups correctly

0 comments on commit 8ef89c3

Please sign in to comment.
Something went wrong with that request. Please try again.