2.0 KiB
title | description | type | page_title | slug | position | tags | ticketid | res_type |
---|---|---|---|---|---|---|---|---|
Display custom error messages on web-based viewer | This article elaborates on how to replace any error message output by the report with a custom error message. | how-to | Display custom error messages on web-based viewer | display-custom-error-messages-on-web-based-viewer | HTML5Viewer, Localization | 1410107 | kb |
Environment
Product | Progress® Telerik® Reporting |
Report Viewer | All web-based viewers |
Description
How do I change the default error messages displayed by the HTML5-based Report Viewers with my custom ones? Example of such a message is the following:
Unable to get report parameters.
An error has occurred.
An error has occurred while resolving X data source: An error occurred while invoking data retrieval method.
Solution
Messages displayed by the HTML5-based Report Viewers are separated into two "categories". While the string "Unable to get report parameters." is a client-side message, the rest of the message is server-side one.
To change the client side text, use the approach demonstrated in the [Localization]({%slug telerikreporting/using-reports-in-applications/display-reports-in-applications/web-application/html5-report-viewer/customizing/localization%}) article and change the corresponding value. However, this won't remove the server-side message. To change the entire message, use the following code snippet:
// Use this logic if you want to change the error message content. Based on the browser culture, you can change the text to different languages.
<script type="text/javascript">
function onError(e, args) {
if (args.indexOf("Unable to get report parameters.")) {
$(".trv-pages-area .trv-error-pane .trv-error-message").html("Custom message here!")
}
...
}
</script>