(e, annotation=None)
| 52 | include_traceback = include_debug_info or '--traceback' in args |
| 53 | |
| 54 | def handle_generic_error(e, annotation=None): |
| 55 | msg = str(e) |
| 56 | if hasattr(e, 'request'): |
| 57 | request = e.request |
| 58 | if hasattr(request, 'url'): |
| 59 | msg = ( |
| 60 | f'{msg} while doing a {request.method}' |
| 61 | f' request to URL: {request.url}' |
| 62 | ) |
| 63 | if annotation: |
| 64 | msg += annotation |
| 65 | env.log_error(f'{type(e).__name__}: {msg}') |
| 66 | if include_traceback: |
| 67 | raise |
| 68 | |
| 69 | if include_debug_info: |
| 70 | print_debug_info(env) |