This is a migrated thread and some comments may be shown as answers.

Global Error logging and handling

1 Answer 646 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
IT Dept
Top achievements
Rank 1
IT Dept asked on 08 Nov 2018, 05:50 PM

This question is two-fold:

First, I've found documentation where you can add an error handler to the Report.Error handler on individual reports, either in the constructor for the report or the usage of it. However, I'm hoping there might be a global way to add a handler to all reports so I can start logging errors during report rendering to ELMAH/etc. Are there any examples of this?

 

Second, once the errors are logged I would like to show a friendlier message on the report view rather than the error stack trace. I've seen am approach where the backend error handler throws an exception which fires the frontend viewer's errror handler to display some text, but could I just overwrite the stack trace info in the error object to a friendlier message in a single place to get that functionality for all reports?

1 Answer, 1 is accepted

Sort by
0
Ivan Hristov
Telerik team
answered on 13 Nov 2018, 11:56 AM
Hello Eric,

Up to your questions:

1. There is no out-of-the-box solution for handling the errors that would occur during report processing on a global level. Each reports handles its own errors in Report.Error event, as you have already noticed. A possible solution would be to inherit all the Report classes from a common class that handles the Error event and provides logging to ELMAH. Another solution is to create a custom TraceListener, attach it to the application configuration file and set it up so it would catch only exceptions thrown from Telerik.Reporting classes. Another option is to handle the exceptions on application level, as shown here.

2. The errors that occur during report item processing do not bubble up to the report viewer by design. The report viewer shows only errors that are related with the report processing and rendering as a whole entity - for example, when the connection to the database is invalid, the report source is not set or the rendering extensions is unavailable. However, instead of overwriting the stack trace, you can load a small report with a friendly error message in the viewer. The reports are loaded asynchronously, so changing the report viewer's report source will immediately load the report with the generic error message. This approach is similar to the way web servers show a single error page when a 404. Not Found occurs.

Hope this helps.

Regards,
Ivan Hristov
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
IT Dept
Top achievements
Rank 1
Answers by
Ivan Hristov
Telerik team
Share this question
or