Current filter:
                                You should refresh the page.
                                  • Hey there!

                                    We're using custom objects that inherit from ObjectDataSource in our reports.
                                    When the Fill method is called and an exception occurs, we're currently catching the exception and throwing a System.FaultException with a user-friendly message.

                                    However, the client is only showing a message stating "Error when trying to populate the datasource.", but no further details are available.
                                    How could we pass the error details back to the client?

                                    Thanks in advance

                                • Yaroslav (DevExpress Support) 09.10.2019

                                  Hi Jan,
                                  >>When the Fill method is called and an exception occurs, we're currently catching the exception
                                  Are you saying that you wrap the ObjectDataSource.Fill method in a try...catch block? If that's correct, where are you doing that and why? Opening any report in the viewer will automatically fill the template with data. Perhaps, you can share relevant source code? This should clarify the situation.

                                  Regards,
                                  Yaroslav

                                • Jan Van der Haegen 1 09.11.2019

                                  Hey Yaroslav!

                                  Yes, exactly. So our reports have a data source which is an instance of this class...

                                  [C#]
                                  public class OurReportDataSource : ObjectDataSource, ITypedList { public override void Fill(IEnumerable<IParameter> sourceParameters) { try { //do magic } catch(Exception) { throw new System.FaultException("This is a message for the user"); } } //etc }

                                  When opening a report, the datasource's Fill method is automatically called. When something goes wrong, we throw an exception with user-friendly message ("This is a message for the user").
                                  However, the report designer or WebDocumentViewer show an error popup with  "Error when trying to populate the datasource", losing all relevant information as to why the data source faited to populate.

                                  Is there any way we can show our actual user friendly error message "This is a message for the user" instead of the generic "Error when trying to populate the datasource"?

                                2 Solutions

                                Creation Date Importance Sort by

                                Fixed:

                                Hello,
                                Thank you for the clarification. I suggest that you follow instructions provided in the Handle Server-Side Errors in the Document Viewer help topic. Please let us know whether this helps you achieve your goal.

                                See also: Handle Server-Side Errors in the Report Designer.

                                Show all comments
                                • Jan Van der Haegen 1 09.12.2019

                                  Hey Jannet!

                                  This is great, we upgraded from 16.5 to 19.5 this week and I didn't know these entry points existed, are they new?

                                  Unfortunately, when our newly implemented CustomWebDocumentViewerExceptionHandler's GetExceptionMessage method is called, the exception that is passed is a DocumentCreationFailedException with the Message "Error when trying to populate the datasource".  The exception we originally thrown is not included as an inner exception, thus at that point we have already lost all information about why the datasource failed to load.

                                  It seems that your code that calls the Datasource.Fill method, catches our exception but then throws a new message without wrapping the original?  Is there anything we can do about this (some setting, etc?).

                                  Thanks in advance, we're so close to a solution

                                • Jan Van der Haegen 1 09.12.2019

                                  Attachment: this is the exception that we throw in our datasource's Fill method

                                • Jan Van der Haegen 1 09.12.2019

                                  Attachment: when our CustomWebDocumentViewerExceptionHandler's GetExceptionMessage method is called, this is the exception we have to work with

                                • Jannet (DevExpress Support) 09.12.2019

                                  Thank you for the clarification, I understand your scenario. Please give me just some more time to check whether or not it would be possible to achieve your goal. I'll update this ticket ASAP.

                                • Jan Van der Haegen 1 09.12.2019

                                  Thank you Jannet :)

                                • Jannet (DevExpress Support) 09.13.2019

                                  Hello,
                                  Just wanted to drop a note that I forwarded this issue to our R&D team for further investigation. Please stay tuned for further news in this thread.

                                • Jan Van der Haegen 1 09.13.2019

                                  Great, thank you Jannet!

                                • Jan Van der Haegen 1 09.13.2019

                                  Hey everyone.

                                  Perhaps this could be helpful...

                                  My datasource (an instance of an ObjectDataSource)'s Fill method seems to be called by DevExpress.XtraReports.Native.DataSourceFiller.Execute method.
                                  There is an try-catch block there that takes always wraps the actual exception by a DataRetrievalException, effectively keeping all information about the original exception as the InnerException.

                                  The former was original called higher up in the stack, by the DevExpress.XtraReports.Web.WebDocumentViewer.Native.Services.DocumentBuilder.StartBuild method. The exception is caught again at this method in a try-catch block. This catch block has a bit of special logic, because if the exception is/has a DataRetrievalException, it swaps the exception for a normal System.Exception with a fixed localized message and no further info, effectively losing all information about the original exception.

                                  The findings above are the result of pure speculation and in no way were followed by decompiling the DevExpress libraries.  ;-) That being said, if they are correct, it would seem I need to request a code change on the DevExpress end to get our CustomWebDocumentViewerExceptionHandler's GetExceptionMessage method to be passed the details about the original exception.  More specifically, at the DevExpress.XtraReports.Web.WebDocumentViewer.Native.Services.DocumentBuilder.StartBuild() method, when investigating the optionalBuildExcption and finding it to be a DataRetrievalException, passing the original exception as the inner exception of the new exception (as would be the case if it were not a DataRetrievalException).

                                  Thanks in advance :-)

                                • Jannet (DevExpress Support) 09.13.2019

                                  Thank you for your investigation and sharing these thoughts with us, we greatly appreciate it. We clearly understand the situation and are working on it. Let's see what we can do in this regard.