Back to Devexpress

IErrorNotifier Interface

xtrareports-devexpress-dot-blazor-dot-reporting-dot-services-e24e1b03.md

latest2.0 KB
Original Source

IErrorNotifier Interface

Allows you to handle errors in the Blazor Report Viewer (the DxReportViewer component).

Namespace : DevExpress.Blazor.Reporting.Services

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

NuGet Package : DevExpress.Blazor.Viewer

Declaration

csharp
public interface IErrorNotifier
vb
Public Interface IErrorNotifier

Remarks

To customize error messages shown the Report Viewer’ UI, implement the IErrorNotifier interface and register your service at application startup.

The following code snippet creates a MyErrorNotifier class. The class is used to display a custom message to end users if a DataRetrievalException occurs:

csharp
using System;
using DevExpress.Blazor.Reporting.Services;

public class MyErrorNotifier : IErrorNotifier {
    public event Action<string> OnErrorMessage;

    public void ProcessError(Exception exception) {
        string message = "Internal Server Error";
            var dataRetrievalException = exception as DevExpress.XtraReports.DataRetrievalException;
            if(dataRetrievalException != null && dataRetrievalException.InnerException is DevExpress.DataAccess.Sql.DatabaseConnectionException) {
            message = "Please try again later.";
        }
        OnErrorMessage?.Invoke(message);
    }
}

Register the MyErrorNotifier class at application startup (the Program.cs file):

csharp
builder.Services.AddScoped<IErrorNotifier, MyErrorNotifier>();

See Also

IErrorNotifier Members

DevExpress.Blazor.Reporting.Services Namespace