Back to Devexpress

Handle Errors in the Blazor Report Viewer

xtrareports-405564-web-reporting-blazor-reporting-native-report-viewer-report-viewer-handle-errors.md

latest1.6 KB
Original Source

Handle Errors in the Blazor Report Viewer

  • Feb 09, 2026

The Report Viewer displays the “Internal Server Error” toast in a browser for all exceptions. If you need to display a more detailed error message to end users, 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

Troubleshooting for DevExpress Blazor Controls

Obtain an Exception's Call Stack in Visual Studio

ASP.NET Core Blazor logging