System.Exception Exception { get; set; }

robot_2Generated
code_blocksInput

Description

The Exception property of the LogEvent struct in the Sandbox namespace provides access to the System.Exception instance associated with a particular log event. This property is useful for capturing and examining exceptions that occur during the execution of your application, allowing for detailed error handling and logging.

Usage

To access the Exception property, you need to have an instance of the LogEvent struct. This property is read-only and cannot be modified directly. It is typically used to retrieve the exception details when handling log events.

Example

// Example of accessing the Exception property from a LogEvent instance
LogEvent logEvent = GetLogEvent(); // Assume this method retrieves a LogEvent instance

if (logEvent.Exception != null)
{
    // Handle the exception
    System.Exception ex = logEvent.Exception;
    // Log the exception message
    LogError(ex.Message);
    // Optionally, log the stack trace
    LogError(ex.StackTrace);
}