Back to Devexpress

IWebDocumentViewerExceptionHandler Interface

xtrareports-devexpress-dot-xtrareports-dot-web-dot-webdocumentviewer-55dc74b3.md

latest4.1 KB
Original Source

IWebDocumentViewerExceptionHandler Interface

Enables you to handle server-side errors in the Web Document Viewer.

Namespace : DevExpress.XtraReports.Web.WebDocumentViewer

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

NuGet Package : DevExpress.Web.Reporting.Common

Declaration

csharp
public interface IWebDocumentViewerExceptionHandler :
    IExceptionHandler
vb
Public Interface IWebDocumentViewerExceptionHandler
    Inherits IExceptionHandler

Remarks

This interface is inherited from the base IExceptionHandler interface and exposes the GetExceptionMessage method that is called when any server-side error occurs.

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

csharp
using System;
using DevExpress.XtraReports.Web.WebDocumentViewer;

public class CustomExceptionHandler : IWebDocumentViewerExceptionHandler {
    public string GetExceptionMessage(Exception ex) {
        return ex.Message;
    }
}
vb
Imports System
Imports DevExpress.XtraReports.Web.QueryBuilder.Services
Imports DevExpress.XtraReports.Web.ReportDesigner.Services
Imports DevExpress.XtraReports.Web.WebDocumentViewer

Public Class CustomExceptionHandler
    Inherits IWebDocumentViewerExceptionHandler

    Public Function GetExceptionMessage(ByVal ex As Exception) As String
        Return ex.Message
    End Function
End Class

To register the implemented exception handler, use the static DefaultWebDocumentViewerContainer.Register method at the application’s startup as shown below:

csharp
void Application_Start(object sender, EventArgs e) {
    \\ ...
    DevExpress.XtraReports.Web.WebDocumentViewer.DefaultWebDocumentViewerContainer.
        Register<IWebDocumentViewerExceptionHandler, CustomExceptionHandler>();
}
vb
Private Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
    ' ...
    DevExpress.XtraReports.Web.WebDocumentViewer.DefaultWebDocumentViewerContainer.
        Register(Of IWebDocumentViewerExceptionHandler, CustomExceptionHandler)()
End Sub

The WebDocumentViewerExceptionHandler class is the predefined implementation of the IWebDocumentViewerExceptionHandler interface.

See the following topics for more information:

See Also

IWebDocumentViewerExceptionHandler Members

DevExpress.XtraReports.Web.WebDocumentViewer Namespace