| 241 | return json(output, dumps=self.dumps) |
| 242 | |
| 243 | def _generate_output(self, *, full): |
| 244 | output = { |
| 245 | "description": self.title, |
| 246 | "status": self.status, |
| 247 | "message": self.text, |
| 248 | } |
| 249 | |
| 250 | for attr, display in (("context", True), ("extra", bool(full))): |
| 251 | info = getattr(self.exception, attr, None) |
| 252 | if info and display: |
| 253 | output[attr] = info |
| 254 | |
| 255 | if full: |
| 256 | _, exc_value, __ = sys.exc_info() |
| 257 | exceptions = [] |
| 258 | |
| 259 | while exc_value: |
| 260 | exceptions.append( |
| 261 | { |
| 262 | "type": exc_value.__class__.__name__, |
| 263 | "exception": str(exc_value), |
| 264 | "frames": [ |
| 265 | { |
| 266 | "file": frame.filename, |
| 267 | "line": frame.lineno, |
| 268 | "name": frame.name, |
| 269 | "src": frame.line, |
| 270 | } |
| 271 | for frame in extract_tb(exc_value.__traceback__) |
| 272 | ], |
| 273 | } |
| 274 | ) |
| 275 | exc_value = exc_value.__cause__ |
| 276 | |
| 277 | output["path"] = self.request.path |
| 278 | output["args"] = self.request.args |
| 279 | output["exceptions"] = exceptions[::-1] |
| 280 | |
| 281 | return output |
| 282 | |
| 283 | @property |
| 284 | def title(self): |