Csla.DataPortalException - Can the InnerException be populated with the root exception?

Csla.DataPortalException - Can the InnerException be populated with the root exception?

Old forum URL: forums.lhotka.net/forums/t/7127.aspx


Jaans posted on Wednesday, June 17, 2009

Using Silverlight and WCF Data Portal to server the async result contains a Error property of type DataPortalException. My question is whether it is possible to have the inner exception populated accordingly?

My issue is that currently the exception (correctly) identifies that (for example) the DataPortal.Create/Fetch/etc. has failed. It embeds the inner/source exception text within its own message text.

I'm interested in that inner exception information alone in certain cases and need to strip away the surrounding dataportal exception detail.

I realise we're serializing here and that the exception information is now withing the client realm so I'm not sure what the best way is here. I do know however that I would like to choose what display and what not, but for that I need the inner exception stack.

Suggestions?

Regards,
Jaans

RockfordLhotka replied on Thursday, June 18, 2009

This was discussed on a thread perhaps 2 weeks ago.

The answer is that we can't serialize arbitrary .NET exceptions to Silverlight. These are two different platforms, and it just isn't possible. Things like SqlException just don't exist on Silverlight, and CSLA can't spoof every exception in .NET (and every other library - I'm sure there is an OracleException too).

So instead, we have the server run through the exception stack and we pull out all the data we can. That goes into the Error property of the client-side exception, so you get as much data as we can provide about the original exception stack.

Jaans replied on Thursday, June 18, 2009

A bit of self loathing it due here... I didn't pickup on the fact that the Exception is of type CslaDataPortalException which has the ErrorInfo that has chain/stack of the coveted information.

I stumbled accross it on the Silverlight FAQ:
http://www.lhotka.net/cslanet/faq/SilverlightFaq.ashx

That's all I needed, in order to show the user the failure (outermost ErrorInfo) and the root cause (innermost ErrorInfo).

Regarding the inner exception on the exception object, I agree, the client side shouldn't and cannot be the same exception stack. These exceptions technically also didn't happen on the client. My initial thoughts were to wrap them in generic exceptions and and maintain the stack, but this is already available on the DataPortalException class.

Thanks Rocky!!

Copyright (c) Marimer LLC