ReportViewer: Catch errors

Hi, I would like to know how I can catch errors that showup on my reportviewer web server control when for instance there is a parameter whose value was not set.
LVL 4
karakavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Juan_BarreraCommented:
Hi,
You can you the ReportError method of the ReportViewer control. It has an 'e' argument of type ReportErrorEventArgs, which you can use to handle the error.
For example, I have a page where I use it like this:
 


Protected Sub ReportViewer1_ReportError(ByVal sender As Object, ByVal e As Microsoft.Reporting.WebForms.ReportErrorEventArgs) Handles ReportViewer1.ReportError 
If TypeOf e.Exception Is AspNetSessionExpiredException Then 
e.Handled = True 
Session.Abandon() 
FormsAuthentication.SignOut() 
Response.Redirect(FormsAuthentication.LoginUrl, True) 
Else 
e.Handled = False 
End If 
End Sub 

Open in new window

0
karakavAuthor Commented:
For my case that method doesn't catch the errors. They are still poping up directly on the control.
0
Juan_BarreraCommented:
karakav,
Do you get the same error if you browse the repot using SSRS Report Manager? Because, if that's the case, the problem is with the report design, not with the report viewer control.
For wht you say in the first post, this may well be the situation.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

karakavAuthor Commented:
Actually I don't care (excuse me for the expression) where the error is comming from, I am looking for a way  of stoping ANY error from poping up on the control.
0
Juan_BarreraCommented:
how do you want to stop it if you don't know where is coming from?
0
karakavAuthor Commented:
Since most of exception classes inherit Exception, I was thinking it is the case for reporting services and that catching that one would be enough but I guess I am wrong. What I meant in my earlier post was that I don't want the user to see the error message. I just want to provide a generic error message.
0
Juan_BarreraCommented:
But that's the problem:
If the exception comes from the ReportViewer itself. you should be able to catch it using the event handler I copied above.
But, if you keep in mind that the ReportViewer ends up being an IFrame, displaying content from other site (the Reports Server), you may guess that it's possible that the error could be in the report itself, and the Viewer won't know anything about it. Believe me, I've seen it :)
So, here it doesn't matter if the exception inherits System.Exception, the important thing is to keep in mind that tthe error can be coming from the RS.
That's why I suggested the approach of checking it through Report Manager, or, I should add now, check the RS execution log, for error.
Unfortunately, if you are really sure that the code above doesn't catch the exception. I don't really see any other way.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karakavAuthor Commented:
Yeah, I am pretty sure this won't catch my exceptions as I already handled those ones that might come out from other sources than the report. And I agree with you that the errors are probably coming inside the report. The problem is that I don't know how to check the report itself for errors.
0
Juan_BarreraCommented:
Well, for starters, you should run the report through SSRS Report Mangager and see what happens.
Also, somebody must been doing the reports definitions and development, so that person should be able to debug it.
0
karakavAuthor Commented:
Thanks any way.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.