Real-Time Web Application Development by Rami Vemula

Real-Time Web Application Development by Rami Vemula

Author:Rami Vemula
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


Create a class named CustomExceptionFilter in the Filters folder of the ASC.Web project. Inherit the class from ExceptionFilterAttribute , as shown in Listing 8-18. The ILogger instance is injected through the constructor that is used in the OnExceptionAsync method to log the exception details to Azure Table storage. Once an exception has been logged, a custom error view will be presented to the user. IModelMetadataProvider is also required to initiate ViewDataDictionary for the Error view.

public class CustomExceptionFilter : ExceptionFilterAttribute

{

private readonly ILogger<CustomExceptionFilter> _logger;

private readonly IModelMetadataProvider _modelMetadataProvider;

public CustomExceptionFilter(ILogger<CustomExceptionFilter> logger, IModelMetadataProvider modelMetadataProvider)

{

_logger = logger;

_modelMetadataProvider = modelMetadataProvider;

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.