Browse Source

fix context: include traceback in case of general catched exception (Issue #58)

Bastien Sevajol 6 years ago
parent
commit
05352708cd
2 changed files with 8 additions and 2 deletions
  1. 4 1
      hapic/context.py
  2. 4 1
      hapic/ext/pyramid/context.py

+ 4 - 1
hapic/context.py View File

202
                     # TODO BS 2018-05-04: How to be attentive to hierarchy ?
202
                     # TODO BS 2018-05-04: How to be attentive to hierarchy ?
203
                     if isinstance(exc, handled_exception.exception_class):
203
                     if isinstance(exc, handled_exception.exception_class):
204
                         error_builder = self.get_default_error_builder()
204
                         error_builder = self.get_default_error_builder()
205
-                        error_body = error_builder.build_from_exception(exc)
205
+                        error_body = error_builder.build_from_exception(
206
+                            exc,
207
+                            include_traceback=self.is_debug(),
208
+                        )
206
                         return self.get_response(
209
                         return self.get_response(
207
                             json.dumps(error_body),
210
                             json.dumps(error_body),
208
                             handled_exception.http_code,
211
                             handled_exception.http_code,

+ 4 - 1
hapic/ext/pyramid/context.py View File

194
             def view_func(exc, request):
194
             def view_func(exc, request):
195
                 # TODO BS 2018-05-04: How to be attentive to hierarchy ?
195
                 # TODO BS 2018-05-04: How to be attentive to hierarchy ?
196
                 error_builder = self.get_default_error_builder()
196
                 error_builder = self.get_default_error_builder()
197
-                error_body = error_builder.build_from_exception(exc)
197
+                error_body = error_builder.build_from_exception(
198
+                    exc,
199
+                    include_traceback=self.is_debug(),
200
+                )
198
                 return self.get_response(
201
                 return self.get_response(
199
                     json.dumps(error_body),
202
                     json.dumps(error_body),
200
                     http_code
203
                     http_code