Question

In the EFContextProvider (EF6) SaveChangesCore method, the exception handling looks like this:

} catch (Exception e) {
while (e.InnerException != null) {
e = e.InnerException;
}
throw e;
}

This throws only the most internal exception and hides the relevant information revealed by the external exceptions.

When the SaveChanges process goes through multiple layers the next direct layer exception is lost, and only the last exception in the chain is thrown. It doesn't allow to handle well the exceptions for the caller.

Was it helpful?

Solution

Updated Post

As of Breeze 1.4.6, any .NET Exceptions thrown on the server are now available in their original form in the httpResponse.data property of any async breeze result. Breeze will still drill down to extract a "good" error message, but will no longer obscure the initial exception.

Original Post Below -------------------

It's an interesting point. The reason we did this was because most client side apps aren't written to navigate thru the exception chain and we wanted to expose the most 'relevant' error to the client. Most of the apps we looked at just exposed the client "error.message" property directly and with EF errors this was almost always useless.

However, your point is well taken. I think what we need to do is create a new Exception that has a top level message that is the innermost exception message but still expose the entire exception chain for those that want to drill. I've added an internal feature request for this and will try to get it into a near term release ( probably not the next one because we are already in testing for that one).

And thanks for the input.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top