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. Exception Handling in 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. Exception Handling in 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. Exception Handling in VB .NET
Try
// create an instance of the class to load the XML file into
BookStoreLib.Bookstore elm = new BookStoreLib.Bookstore();
elm.FromXmlFile(filename);
Catch ex As Exception
DisplayError(ex);
End Try
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
E.g. Exception Handling in Java
try
{
// create an instance of the class to load the XML file into
bs.Bookstore elm = new bs.Bookstore();
elm.fromXmlFile(filename);
}
catch (Exception e)
{
// Note : exceptions are likely to contain inner exceptions
// that provide further detail about the error.
Throwable te = e;
while (te != null)
{
System.out.println("error - " + te.getMessage());
te = te.getCause();
}
}
E.g. Exception Handling in VB6
On Error Goto Failed
Dim oElm As Object
Set oElm = BookstoreLib.FromXmlFile(filename)
oElm.FromXmlFile filename
Failed:
MsgBox "Error - " & Err.Description
Article ID: 75, Created: 1/27/2011 at 9:11 AM, Modified: 11/7/2016 at 10:03 AM