Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IExceptionHandler.GetExceptionMessage(Exception) Method

Enables you to handle all server-side errors.

Namespace: DevExpress.XtraReports.Web.ClientControls

Assembly: DevExpress.XtraReports.v24.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

#Declaration

string GetExceptionMessage(
    Exception ex
)

#Parameters

Name Type Description
ex Exception

An exception that occurs on the server side.

#Returns

Type Description
String

A string to show in a browser when an error occurs.

#Remarks

The GetExceptionMessage method is called when any server-side error occurs.

The following code snippet demonstrates how to implement this method and return an actual exception message:

using System;
using DevExpress.XtraReports.Web.QueryBuilder.Services;
using DevExpress.XtraReports.Web.ReportDesigner.Services;
using DevExpress.XtraReports.Web.WebDocumentViewer;

public class CustomExceptionHandler : IReportDesignerExceptionHandler, 
    IWebDocumentViewerExceptionHandler, IQueryBuilderExceptionHandler {
    public string GetExceptionMessage(Exception ex) {
        return ex.Message;
    }
}

To register the implemented exception handler, use the static methods at the application’s startup as shown below:

void Application_Start(object sender, EventArgs e) {
    // ...
    DevExpress.XtraReports.Web.WebDocumentViewer.DefaultWebDocumentViewerContainer.
        Register<IWebDocumentViewerExceptionHandler, CustomExceptionHandler>();
    DevExpress.XtraReports.Web.ReportDesigner.DefaultReportDesignerContainer.
        Register<IReportDesignerExceptionHandler, CustomExceptionHandler>();
    DevExpress.XtraReports.Web.QueryBuilder.DefaultQueryBuilderContainer.
        Register<IQueryBuilderExceptionHandler, CustomExceptionHandler>();
}
See Also