Changeset View
Changeset View
Standalone View
Standalone View
swh/web/utils/exc.py
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | if get_config()["debug"]: | ||||
error_description = traceback.format_exc() | error_description = traceback.format_exc() | ||||
logger.debug(error_description) | logger.debug(error_description) | ||||
if isinstance(exc, BadInputExc): | if isinstance(exc, BadInputExc): | ||||
error_code = 400 | error_code = 400 | ||||
if isinstance(exc, ForbiddenExc): | if isinstance(exc, ForbiddenExc): | ||||
error_code = 403 | error_code = 403 | ||||
if isinstance(exc, NotFoundExc): | if isinstance(exc, NotFoundExc): | ||||
error_code = 404 | error_code = 404 | ||||
else: | |||||
# some NotFoundExc texts have HTML links we want to preserve | |||||
error_description = escape(error_description) | |||||
resp = _generate_error_page(request, error_code, error_description) | resp = _generate_error_page(request, error_code, error_description) | ||||
if get_config()["debug"]: | if get_config()["debug"]: | ||||
resp.traceback = error_description # type: ignore[attr-defined] | resp.traceback = error_description # type: ignore[attr-defined] | ||||
return resp | return resp |