seitime-frappe/frappe/website/page_renderers/error_page.py
Suraj Shetty 1431cb26d3 fix: Catch any expection and show proper error page
- Also, show title & message if it is defined in the exception class
2022-06-01 08:08:52 +05:30

17 lines
604 B
Python

from frappe.website.page_renderers.template_page import TemplatePage
class ErrorPage(TemplatePage):
def __init__(self, path=None, http_status_code=None, exception=None):
path = "error"
super().__init__(path=path, http_status_code=http_status_code)
self.exception = exception
def can_render(self):
return True
def init_context(self):
super().init_context()
self.context.http_status_code = getattr(self.exception, "http_status_code", None) or 500
self.context.error_title = getattr(self.exception, "title", None)
self.context.error_message = getattr(self.exception, "message", None)