How to Customize Error Messages in Report Viewer
Published:
Updated:
When an error occurs during report processing in the Bold Reports Viewer, the reportError event is triggered. You can handle this event to suppress the default error dialog displayed by the viewer and instead show a custom message.
To prevent the default error dialog from appearing, set args.cancel = true inside the event handler.
Steps to customize error messages
Step 1: Modify the error message
- Use the following code snippet in your
HTMLfile to display a custom alert message instead of the default technical error details.
<script type = "text/javascript">
function onReportError(args) {
// Show your message instead of the default error
alert("Something went wrong while loading the report. Please try again or contact support.");
args.cancel = true; // prevents the built-in error UI
}
$(function () {
$("#viewer").boldReportViewer({
reportServiceUrl: "https://demos.boldreports.com/services/api/ReportViewer",
processingMode: ej.ReportViewer.ProcessingMode.Local,
reportError: onReportError
});
});
</script>
Code definition
| Code snippet | Description |
|---|---|
onReportError(args) |
Handles errors raised during report processing in the Report Viewer. |
args.errmsg |
Contains the actual error message returned during report processing. |
alert(args.errmsg) |
Displays the error message in a browser alert popup. |
args.cancel = true |
Prevents the default Bold Reports error dialog from appearing. |
reportError: onReportError |
Assigns the custom error handler so all viewer errors are routed to onReportError. |
This configuration ensures that when an error occurs in the Report Viewer, users see a custom alert message instead of the default technical error dialog.
Preview
Download the sample application from the following link.