How to handle errors/exceptions?

7 posts, 0 answers
  1. Datamex
    Datamex avatar
    161 posts
    Member since:
    Jun 2012

    Posted 15 Jun 2011 Link to this post

    Hi there,

    I really want to let the users know whenever an error or exception occurs while a report is generated. I use a ReportViewer to display my reports and I have an errorlabel placed above the viewer.

    It is possible, due to rights, that a user cannot retrieve certain data and therefore the viewer throws an error message, but I want to show an "informative" message in an errorlabel outside the report, above the viewer itself on the .aspx page. Whenever this error or exception occurs I want to NOT generate the report (just abort it and show no report) and display corresponding error message in the errorlabel on the aspx page.

    In my code-behind of my .aspx page I have the following:
    CustomReport customReport = new CustomReport();
    // ...set reportparameters...
    this.ReportViewer.Report = customReport;
    // report is getting generated and viewer shows an error

    For all of you, I don't use a ReportProcessor, so the Error event of it cannot be used. The Error event of the report itself cannot be used as well, because it's located in another DLL and not accessible in my .aspx page. So why isn't there an event such as the Error event of the ReportProcessor and report for the ReportViewer? 

    I really want to solve this, because I don't want to show the users a report with only an error in it. I don't want to show the report at all if an error/exception occurs and this error/exception details should be displayed in the errorlabel.

    Looking forward to a solution or workaround! Thanks in advance!

  2. Peter
    Peter avatar
    1631 posts

    Posted 17 Jun 2011 Link to this post

    Hello Datamex,

    Report handling is time consuming task. Thus to improve the user experience we let the page to render and after that report handler is processing reports. At the moment when report error occurs the page is already rendered and changing control properties will not have the expected result. Thus our suggestion is to design your reports in an error proof way and eliminate any error while designing the reports.

    Still if for any reason this is not applicable for your scenario. In order to check for errors to hide the report error and show custom message you have to subscribe for Report.Error event, do a test report rendering and if the error handler is fired do the necessary updates as shown in the following code snippet:

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            var report = new Telerik.Reporting.Examples.CSharp.ProductSales();
            this.ReportViewer.Report = report;
            report.Error += delegate(object innerSender, ErrorEventArgs eventArgs)
                this.ReportViewer.Report = null;
                this.Label1.Text = eventArgs.Exception.Message.ToString();
            new ReportProcessor().RenderReport("HTML", report, null);

    Best wishes,
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items
  3. Wang
    Wang avatar
    19 posts
    Member since:
    Jul 2011

    Posted 29 Dec 2011 Link to this post

    Hello Peter,
        In case of the report be shown by using the Silverlight ReportViewer.
        How can I catch the report exception when  the executed mdx query against OLAP cube has exception?
        At this moment,I use the Telerik.Reporting Version is

        Please see the code below
    <%@ServiceHost  Service="Telerik.Reporting.Service.ReportService, Telerik.Reporting.Service, Version=, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" %>

    <telerik:ReportViewer x:Name="MyReportViewer"  
    Report="ReportLibrary.ReportFile.ReportTest, ReportLibrary"

    this.MyReportViewer.RenderBegin += new RenderBeginEventHandler(ReportViewer_RenderBegin);
    this.MyReportViewer.Report = "ReportLibrary.ReportFile.ReportTest, ReportLibrary";

    I  create the report instance by using the "ReportService.svc" wcf service.
    I  can only set the completely named report for the Silverlight ReportViewer's Report Property.

    How should I do ?
    I am in urgent need of yours help.Thanks
  4. Jyoti
    Jyoti avatar
    1 posts
    Member since:
    Jun 2012

    Posted 15 Jun 2012 Link to this post


    I am facing time out exceptions in case the data set is large. I need to show friendly message incase there is any exception being thrown by the report. I have tried the solution provided by you, but still the error message is displayed inside the report viewer control. Can you please provide complete solution for showing friendly message in a label control when an unhandled exception occurs.

  5. Mukul
    Mukul avatar
    5 posts
    Member since:
    Nov 2011

    Posted 30 Apr 2013 Link to this post


    I have the exact same issue as Wang's (Posted on Dec 29, 2011). The reportviewer in my silverlight application fetches the report generated from service. I may get unexpected exception in which case I do NOT want to load the report with exception. Instead I would just like to display 'No Report'.
    I am using version of Reportviewer.
    Is there a way to check for the exception and prevent loading the report with exception yet? Urgently in need of a solution for this.


  6. Squall
    Squall avatar
    180 posts
    Member since:
    Feb 2011

    Posted 03 May 2013 Link to this post

    Hi guys,

    I use the reportservice client to handle service related errors:
    public partial class MainPage : UserControl, IReportServiceClientFactory
        public MainPage()
            this.ReportViewer1.ReportServiceClientFactory = this;
        ReportServiceClient IReportServiceClientFactory.Create(System.Uri remoteAddress)
            var binding = new BasicHttpBinding() // or BasicHttpBinding(BasicHttpSecurityMode.Transport) overload if SSL is used
                MaxBufferSize = int.MaxValue,
                MaxReceivedMessageSize = int.MaxValue,
                ReceiveTimeout = new TimeSpan(0, 15, 0),
                SendTimeout = new TimeSpan(0, 15, 0),
                //uncomment to check the error handling mechanics
                //ReceiveTimeout = new TimeSpan(0, 0, 1),
                //SendTimeout = new TimeSpan(0, 0, 1),
            var endpointAddress = new EndpointAddress(remoteAddress);
            var client = new ReportServiceClient(binding, endpointAddress);
            client.RenderAndCacheCompleted += new EventHandler<RenderAndCacheEventArgs>(client_RenderAndCacheCompleted);
            return client;
        void client_RenderAndCacheCompleted(object sender, RenderAndCacheEventArgs e)
            if (null != e.Error)
                this.ReportViewer1.Visibility = Visibility.Collapsed;

    As you see on error I collapse the viewer, another option is to show a viewer that displays no report or anything else to alert the user about the error.
  7. Mukul
    Mukul avatar
    5 posts
    Member since:
    Nov 2011

    Posted 24 May 2013 Link to this post

    Thanks a lot Squall. That solves my problem perfectly. Thank  you all the more as the response I got from my Telerik support correspondent was 'Catching internal report errors is not possible in Silverlight'.
Back to Top