When the HandleError attribute on a controller detects an unhandled exception and redirects to the Error view, I would like to provide the user with a brief description of the error, and an option to email the error to the application administrator.
I do have a custom HandleError that notifies Elmah to log the error, but having to look up the error in the Elmah log seems a bit of a last resort. Is there any other way to access the unhandled exception that is ‘caught’ by HandleError?
HandleErrorAttributesupplies a Model object of typeHandleErrorInfoYour Error page could look like this
The Model has an
Exceptionproperty with the details of the exception handled.I usually use a custom error handler that also logs the exception using log4net and I have an STMP appender that emails me whenever an exception is handled by the filter.