Class ErrorsEventArgs
- Namespace
- VisioForge.Core.Types.Events
- Assembly
- VisioForge.Core.dll
Provides data for error events, encapsulating details about an error or warning that occurred within the framework.
public class ErrorsEventArgs : EventArgsInheritance
Inherited Members
Examples
// Assume an event handler is registered for an error event.
public void OnErrorOccurred(object sender, ErrorsEventArgs e)
{
Console.WriteLine($"[{e.Timestamp}] {e.Level}: {e.Message}");
if (!string.IsNullOrEmpty(e.CallSite))
{
Console.WriteLine($" Call Site: {e.CallSite}");
}
if (!string.IsNullOrEmpty(e.StackTrace))
{
Console.WriteLine($" Stack Trace:{e.StackTrace}");
}
if (!string.IsNullOrEmpty(e.AssemblyVersion))
{
Console.WriteLine($" Assembly Version: {e.AssemblyVersion}");
}
// Depending on the error level, you might log to a file, display a message to the user, or take corrective action.
if (e.Level == DebugLevel.Error)
{
// Log critical error and potentially shut down or restart a component.
}
}
Remarks
This class is used to convey diagnostic information, including the severity level, a descriptive message, and contextual details like the call site and stack trace. It is crucial for debugging and monitoring the health of applications built with VisioForge components. The Level property indicates severity (Error, Warning, Info, Debug) allowing appropriate response handling. Timestamp property provides precise timing for correlation with other application events and logs. CallSite and StackTrace properties offer detailed diagnostic information for debugging production issues. AssemblyVersion helps identify which framework version generated the error, useful for version-specific troubleshooting. Error events may be raised from background processing threads, requiring thread-safe handling and UI marshaling. Applications should implement appropriate logging, user notifications, and recovery strategies based on error severity. Critical errors (Level.Error) may require stopping operations, while warnings can often be logged without interruption. Consider integrating with application logging frameworks (Serilog, NLog, etc.) for comprehensive error tracking.
Constructors
ErrorsEventArgs(DebugLevel, DateTime, string, string, string, string)
Initializes a new instance of the VisioForge.Core.Types.Events.ErrorsEventArgs class with full details.
public ErrorsEventArgs(DebugLevel level, DateTime timestamp, string message, string callsite = "", string assemblyVersion = "", string stackTrace = "")Parameters
levelDebugLevel-
The VisioForge.Core.Types.DebugLevel of the error.
timestampDateTime-
The DateTime when the error occurred.
messagestring-
The error message text.
callsitestring-
The call site where the error originated (optional).
assemblyVersionstring-
The version of the assembly where the error occurred (optional).
stackTracestring-
The stack trace of the error (optional).
ErrorsEventArgs(DebugLevel, string)
Initializes a new instance of the VisioForge.Core.Types.Events.ErrorsEventArgs class with a specified level and message. The timestamp is set to the current time.
public ErrorsEventArgs(DebugLevel level, string message)Parameters
levelDebugLevel-
The VisioForge.Core.Types.DebugLevel of the error.
messagestring-
The error message text.
Properties
AssemblyVersion
Gets the version of the assembly where the error or event occurred.
public string AssemblyVersion { get; }Property Value
CallSite
Gets the location in the code where the error or event originated.
public string CallSite { get; }Property Value
Level
Gets the severity level of the error or message.
public DebugLevel Level { get; }Property Value
Message
Gets a descriptive message about the error or event.
public string Message { get; }Property Value
StackTrace
Gets the stack trace associated with the error, providing details about the call sequence.
public string StackTrace { get; }Property Value
Timestamp
Gets the timestamp when the error or event occurred.
public DateTime Timestamp { get; }Property Value
Methods
ToString()
Returns a string that represents the current VisioForge.Core.Types.Events.ErrorsEventArgs instance. By default, this returns the VisioForge.Core.Types.Events.ErrorsEventArgs.Message.
public override string ToString()