Skip to main content

WebDocumentViewerExceptionHandler.GetDocumentCreationExceptionMessage(DocumentCreationException) Method

Enables you to handle errors related to the document creation process.

Namespace: DevExpress.XtraReports.Web.WebDocumentViewer

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

NuGet Package: DevExpress.Web.Reporting.Common

Declaration

public virtual string GetDocumentCreationExceptionMessage(
    DocumentCreationException ex
)

Parameters

Name Type Description
ex DocumentCreationException

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 GetDocumentCreationExceptionMessage method is called whenever an error occurs while the document creation is in process (for instance, errors in the BeforePrint or AfterPrint events of a report or specific control).

The code snippet below demonstrates how to create a descendant from the WebDocumentViewerExceptionHandler class and override the GetDocumentCreationExceptionMessage method to return a custom message.

using DevExpress.XtraReports.Web.WebDocumentViewer;

public class CustomWebDocumentViewerExceptionHandler : WebDocumentViewerExceptionHandler {
    public override string GetDocumentCreationExceptionMessage(DocumentCreationException ex) {
        return "An exception occured while document creation.";
    }
}

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

void Application_Start(object sender, EventArgs e) {
    // ...
    DevExpress.XtraReports.Web.WebDocumentViewer.DefaultWebDocumentViewerContainer.
      Register<IWebDocumentViewerExceptionHandler, CustomWebDocumentViewerExceptionHandler>();
}

See the following topics for more information:

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the GetDocumentCreationExceptionMessage(DocumentCreationException) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also