views:

29

answers:

3

I'm working on a traditional ASP.NET application where I'm making a WCF call to perform some operations.

The question is, should I put a try catch around the WCF call and display the error details at the top of the current page, or let the error redirect the user to a custom error page, or the dreaded yellow screen of death?

A: 

If you expect that the WCF call can throw an exception and you know which exception types you can get, then yes, you should catch the exception and perform the appropriate action. Usually it is a good idea to tell the user just that an error made the operation to fail, and log the exception detail for further examination by you or the technical support.

Konamiman
+1  A: 

This will depend on your application requirements. Can you continue processing if the web service call fails? If not you probably should log the exception and redirect the user to a 500 page. I would use Application_Error method in global.asax to do this. If you can continue the processing then you should put a try/catch around your web service call and handle the appropriate FaultException. You should never let customers see the yellow screen in production.

Darin Dimitrov
+2  A: 

Never to the yellow screen of death. The detailed information about the error can give hints to a hacker to break your site.

If the page cannot be displayed without the service request, then redirect to a custom error page.

If only a small portion of information will be missing on a page which is not key to its function, then better display a friendly message to the user that this particular piece of information is not available at the moment.

Developer Art