Retrieving Exception Information

wwDotNetBridge captures the last exception of requests made into .NET through wwDotnetBridge via functions like CreateInstance(), InvokeMethod(), GetProperty(), SetProperty() etc. in the oLastException property and the LastException property on the .oDotNet object instance.

These exceptions can be used for further examination of errors that occurred which is useful if .NET throws more detailed exceptions that provide more information than just the Message property which normally serves up error information.

Typical .NET Exceptions include a Message property, a StackTrace (showing .NET code locations if in Debug mode), and an InnerException if the exception has a base exception that was re-thrown (quite common actually). You can access these properties in FoxPro code like this:

loResult = loBridge.InvokeMethod("SomeMethodThatFails","Parm1")

IF ISNULL(loResult)
    ? loBridge.oLastException.Message
    ? loBridge.oLastException.StackTrace
    IF !ISNULL(loBridge.oLastException.InnerException)
        ? loBridge.oLastException.InnerException.Message 

© West Wind Technologies, 2023 • Updated: 07/10/18
Comment or report problem with topic