Create a technical server error response. The last three arguments are the values returned from sys.exc_info() and friends.
(request, exc_type, exc_value, tb, status_code=500)
| 63 | @csp_override({}) |
| 64 | @csp_report_only_override({}) |
| 65 | def technical_500_response(request, exc_type, exc_value, tb, status_code=500): |
| 66 | """ |
| 67 | Create a technical server error response. The last three arguments are |
| 68 | the values returned from sys.exc_info() and friends. |
| 69 | """ |
| 70 | reporter = get_exception_reporter_class(request)(request, exc_type, exc_value, tb) |
| 71 | preferred_type = request.get_preferred_type(["text/html", "text/plain"]) |
| 72 | if preferred_type == "text/html": |
| 73 | html = reporter.get_traceback_html() |
| 74 | return HttpResponse(html, status=status_code, content_type="text/html") |
| 75 | else: |
| 76 | text = reporter.get_traceback_text() |
| 77 | return HttpResponse( |
| 78 | text, status=status_code, content_type="text/plain; charset=utf-8" |
| 79 | ) |
| 80 | |
| 81 | |
| 82 | @functools.lru_cache |