Back to Devexpress

ExceptionService.ShouldHandleException(Exception) Method

expressappframework-devexpress-dot-expressapp-dot-blazor-dot-services-dot-exceptionservice-dot-shouldhandleexception-x28-system-dot-exception-x29.md

latest2.5 KB
Original Source

ExceptionService.ShouldHandleException(Exception) Method

Specifies how an exception is processed. If you want to process an exception through IExceptionHandlerService, override this method and return true; if you want to process an exception through ErrorBoundary - return false.

Namespace : DevExpress.ExpressApp.Blazor.Services

Assembly : DevExpress.ExpressApp.Blazor.v25.2.dll

NuGet Package : DevExpress.ExpressApp.Blazor

Declaration

csharp
public virtual bool ShouldHandleException(
    Exception exception
)
vb
Public Overridable Function ShouldHandleException(
    exception As Exception
) As Boolean

Parameters

NameTypeDescription
exceptionException

A Exception object.

|

Returns

TypeDescription
Boolean

true to use IExceptionHandlerService; false for ErrorBoundary.

|

Remarks

Override this method to indicate how you want to process an exception. See the following code snippet for an example:

csharp
using System;
using DevExpress.ExpressApp.Blazor.Services;
using Microsoft.Extensions.Logging;
using DevExpress.ExpressApp;

    public class CustomExceptionHandlerService : ExceptionService {
        public CustomExceptionHandlerService(ILogger<ExceptionService> logger) : base(logger) { 
        }
        public override bool ShouldHandleException(Exception exception) {
            if(exception is MyException) {
                return true;
            }
            else {
                return false;
            }
        }
    }

See Also

ExceptionService Class

ExceptionService Members

DevExpress.ExpressApp.Blazor.Services Namespace