Home>Knowledge Base>Support FAQ>Liquid XML Data Binding>How can I get more detailed error information when loading XML data?
Information
Article ID75
Created On1/27/2011
Modified2/24/2011
Share With Others

How can I get more detailed error information when loading XML data?

When the Liquid Runtime throws an Exception, more detailed information can be extracted by catching the exception and recursively look at the inner exception values.

You can see an example of this if you select the option to generate a SampleApp in the Wizard.

E.g. For C#

try
{
    // create an instance of the class to load the XML file into
    BookStoreLib.Bookstore elm = new BookStoreLib.Bookstore();
    elm.FromXmlFile(filename);
}
catch (Exception e)
{
    DisplayError(e);
}

private void DisplayError(Exception ex)
{
    string errText = "Error - \n";
    // Note : exceptions are likely to contain inner exceptions
    // that provide further detail about the error.

    while (ex != null)
    {
        errText += ex.Message +
"\n";
        ex = ex.InnerException;
    }
    MessageBox.Show(this, errText, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}


E.g. For C++

try
{
    // create an instance of the class to load the XML file into
    BookStoreLib::CBookstorePtr elm = BookStoreLib::CBookstore::CreateInstance();
    elm->FromXmlFile(lpctFilename);
}
catch (CLtException& e)
{
    // Note : exceptions are likely to contain inner exceptions
    // that provide further detail about the error, GetFullMessage
    // concatenates the messages from them all.
    _tprintf(_T("Error - %s\n"), e.GetFullMessage().c_str());
}


E.g For VB .NET

 

 

private Sub DisplayError(ByVal ex as Exception)
    Dim errText As String = "Error - " & vbCrLf
    ' Note : exceptions are likely to contain inner exceptions
    ' that provide further detail about the error.
    Do while (Not ex Is Nothing)
        errText = errText & ex.Message & vbCrLf
        ex = ex.InnerException
    Loop

    MessageBox
.Show(Me, errText, "An Error occured.", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub