python - Django: How to get exception instance in error handlers -
django has built-in default views used automatically when exceptions such permissiondenied
, http404
, suspiciousoperation
, etc. raised. convenient feature of django love, seems have limitation.
i raising exception message: raise permissiondenied('you not xyz , have no access foobar')
is there context variable containing original exception instance available in templates (i.e. 403.html
) called original error handlers can access message?
if not, possible hold of original exception custom handler (settings.handler403
, etc.) can inject context?
note: believe can create custom middleware process_exception
, avoid if possible since guess duplicating lot of existing django logic , it's cleaner reuse it. also, looks custom process_exception
override logging in django.core.handlers.base
amongst other behaviors. re-implementing sake of injecting exception info error template seemed kind of silly.
this feature has been implemented ticket 24733.
in django 1.9 , later, exception passed error handlers.
Comments
Post a Comment