All docs
V21.1
21.2 (EAP/Beta)
21.1
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Standard 2.0+
.NET Framework 4.5.2+
The page you are viewing does not exist in the .NET Framework 4.5.2+ platform documentation. This link will take you to the parent topic of the current section.
.NET Standard 2.0+
.NET Core 3.0+

ExceptionService Class

A service that provides access to a custom exception handling.

Namespace: DevExpress.ExpressApp.Blazor.Services

Assembly: DevExpress.ExpressApp.Blazor.v21.1.dll

Declaration

public class ExceptionService :
    IExceptionHandlerService,
    IExceptionProviderService

Remarks

Override the ExceptionService.HandleException(Exception) method in the class descendant to wrap an exception in a user-friendly exception.

The following example demonstrates how to display user-friendly exception in your XAF Blazor UI application:

  1. Add a controller:

    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Actions;
    using System;
    
    namespace MySolution.Module.Controllers {
        public class MyTestException : Exception {
        }
    
        public partial class TestExceptionController : ViewController {
            public TestExceptionController() {
                // When a user clicks this action, an exception is thrown.
                SimpleAction simpleAction = new SimpleAction(this, "Test Action", DevExpress.Persistent.Base.PredefinedCategory.Edit);
                simpleAction.Execute += SimpleAction_Execute;
            }
    
            private void SimpleAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
                throw new MyTestException();
            }
        }
    }
    
  2. Add a MyTestExceptionService service and override the HandleException method:

    public class MyTestExceptionService : ExceptionService {
        public MyTestExceptionService(ILogger<ExceptionService> logger) : base(logger) { }
        public override void HandleException(Exception exception) {
            Exception result = exception is MyTestException ? new UserFriendlyException("My Test User Friendly Exception", exception) : exception;
            base.HandleException(result);
        }
    }
    
  3. Register the MyTestExceptionService service in the MySolution.Blazor.Server\Startup.cs file:

    // ...
    services.AddXaf<MySolutionBlazorApplication>(Configuration);
    // Register the service.
    services.AddScoped<IExceptionHandlerService, MyTestExceptionService>();
    // ...
    
  4. Run the application and click the Test Action button. The user-friendly exception is displayed within a toast notification.

    xaf blazor user friendly url

Inheritance

Object
ExceptionService
See Also