Errors From Data Portal are all generic Async Error

Errors From Data Portal are all generic Async Error

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


thaehn posted on Thursday, March 20, 2014

Hi,

Before upgrading from 4 to 4.5, exceptions coming back from the data portal would have the message of the original exception such as "Another user has modified the row in Table1, update failed".  Now all that comes back as the message is than an Async Error occurred.  There is no detail as to the problem.  What is the method that people are using to return the [collapse]original message such as a table update failed back to the client?

Todd Haehn

[/collapse]

JonnyBee replied on Friday, March 21, 2014

Hi,

Look at the inner exception.

thaehn replied on Friday, March 21, 2014

I have done that.  there isn't any.  My error dialog recurses through the exceptions to get the innermost one.

thaehn replied on Wednesday, April 09, 2014

The exception is coming back to the data portal:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><UpdateResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><UpdateResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Mobile" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.AggregateException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.DataPortalException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.Reflection.CallMethodException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>System.InvalidCastException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>Specified cast is not valid.</a:Message><a:Source>System.Data</a:Source><a:StackTrace …

My code is capturing the error on the client and rethrowing it:

                DateTime start = DateTime.Now;

                TransferMonitorGetTransferSetCommand.BeginExecute(Model.Dc.Id, Model.TransferFrom, Model.TransferTo, (o, e) =>

                {

                    if (e.Error != null)

                    {

                        throw e.Error;

                    }

                    else

                    {

                        Model.UpdateResults(e.Object.TransferSetList);

                        TimeSpan runTime = DateTime.Now - start;

                        UpdateStatus(string.Format("Selected {0:N0} rows In {1} minutes {2}.{3} seconds", Model.TransferSetList.Count, runTime.ToString("%m"), runTime.ToString("%s"), runTime.ToString("%f")), false);

                    }

                });

But the inner exception is NULL and e.Error.Message is "One or more errors occurred." The stack trace is only SystemRuntime.ComplierServices.AsyncServices(ThrowAsync>b_O(Object state). 

Todd

 

thaehn replied on Wednesday, April 16, 2014

The original exception is being returned back to the client as shown in this captured message:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><UpdateResponse xmlns="http://ws.lhotka.net/WcfDataPortal"><UpdateResult xmlns:a="http://schemas.datacontract.org/2004/07/Csla.Server.Hosts.Mobile" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorData><a:ExceptionTypeName>System.AggregateException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.DataPortalException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>Csla.Reflection.CallMethodException</a:ExceptionTypeName><a:InnerError><a:ExceptionTypeName>System.InvalidCastException</a:ExceptionTypeName><a:InnerError i:nil="true"/><a:Message>Unable to cast object of type 'System.DateTime' to type 'System.String'.</a:Message><a:Source>System.Data</a:Source><a:StackTrace>   at System.Data.SqlClient.SqlBuffer.get_String()&#xD…

 

But the error that is coming back in the code:

            UpdateStatus("Generating Commercial Invoice", true);

            TransferMonitorCommercialInvoiceCommand.BeginExecute(

                Model.Id,

                (o, e) =>

                    {

                        if (e.Error != null)

                        {

                            UpdateStatus(string.Empty, false);

                            throw e.Error;

                        }

                        else

                        {

                            Workbook workbook = new Workbook();

                            Worksheet worksheet = workbook.Worksheets.Add();

                          

                         }

                    });

 

Is this:

“One or more errors occurred.” With a stack trace of System.Runtime.CompilerServices.AsyncServices.<ThrowAsync>b__0(Object state).

The inner exception is NULL.

Todd

thaehn replied on Wednesday, April 30, 2014

This appears to be a bug in CSLA's async implementation.  It worked fine in CSLA 4.

Todd

RockfordLhotka replied on Saturday, May 03, 2014

Not a bug, a feature :)

It turns out that when you await a method that numerous things could occur within that method - even in parallel - and so it is possible for multiple exceptions to be returned.

The only correct way to return exceptions from an async method is with an async exception - which is really a collection of exceptions that may have been raised by the various tasks that ran in the method.

In simple code (most code) this will be a collection of one element - which is the actual exception you are looking for.

thaehn replied on Monday, May 05, 2014

Rocky,

Do you have an example I could use?  I am mostly interested in errors returned from SQL (In my example the DBA changed the type of a column from string to date which caused a cast issue because I was expecting a string which I was casting to a date.

Todd

thaehn replied on Monday, May 04, 2015

I updated to 4.5.7 and this "feature" went away.  I am getting error messages back to Silverlight from the data portal again. 

Copyright (c) Marimer LLC