In Silverlight I use lambdas for data retrieval from my service (in this example a WCF Data Service). Exceptions inside the callback get swallowed up by the system unless I handle them with a try catch. For Example:
this.Context.BeginSaveChanges(() =>
{
// throwing an exception is lost and the Application_UnhandledException doesn't catch it
}, null);
I have a helper function to log the exception and redirect to a aspx general error page, but then I have to wrap everything in lambdas with try/catches which is ok, if I have to do it, but is there a better way?
You could create a set of helper methods to wrap the lambda’s with:-
Now you can wrap lambda’s without worrying about default boilerplate exception handling:-