|
|
@@ -125,7 +125,12 @@ def handle_exception(e): |
|
|
|
http_status_code = getattr(e, "http_status_code", 500) |
|
|
|
return_as_message = False |
|
|
|
|
|
|
|
if (http_status_code==500 |
|
|
|
if frappe.local.is_ajax or 'application/json' in frappe.local.request.headers.get('Accept', ''): |
|
|
|
# handle ajax responses first |
|
|
|
# if the request is ajax, send back the trace or error message |
|
|
|
response = frappe.utils.response.report_error(http_status_code) |
|
|
|
|
|
|
|
elif (http_status_code==500 |
|
|
|
and isinstance(e, MySQLdb.OperationalError) |
|
|
|
and e.args[0] in (1205, 1213)): |
|
|
|
# 1205 = lock wait timeout |
|
|
@@ -133,13 +138,13 @@ def handle_exception(e): |
|
|
|
# code 409 represents conflict |
|
|
|
http_status_code = 508 |
|
|
|
|
|
|
|
if http_status_code==401: |
|
|
|
elif http_status_code==401: |
|
|
|
frappe.respond_as_web_page(_("Session Expired"), |
|
|
|
_("Your session has expired, please login again to continue."), |
|
|
|
http_status_code=http_status_code, indicator_color='red') |
|
|
|
return_as_message = True |
|
|
|
|
|
|
|
if http_status_code==403: |
|
|
|
elif http_status_code==403: |
|
|
|
frappe.respond_as_web_page(_("Not Permitted"), |
|
|
|
_("You do not have enough permissions to complete the action"), |
|
|
|
http_status_code=http_status_code, indicator_color='red') |
|
|
@@ -151,10 +156,6 @@ def handle_exception(e): |
|
|
|
http_status_code=http_status_code, indicator_color='red') |
|
|
|
return_as_message = True |
|
|
|
|
|
|
|
|
|
|
|
elif frappe.local.is_ajax or 'application/json' in frappe.local.request.headers.get('Accept', ''): |
|
|
|
response = frappe.utils.response.report_error(http_status_code) |
|
|
|
|
|
|
|
else: |
|
|
|
traceback = "<pre>"+frappe.get_traceback()+"</pre>" |
|
|
|
if frappe.local.flags.disable_traceback: |
|
|
|