internal Event(string context, Metadata metadata, App app, Device device, User user, Exception[] exceptions, HandledState handledState, Breadcrumb[] breadcrumbs, Session session, LogType?logType = null) { OriginalSeverity = handledState; Metadata = metadata; HandledState = handledState; LogType = logType; this.AddToPayload("context", context); this.AddToPayload("payloadVersion", 4); this.AddToPayload("exceptions", exceptions); this.AddToPayload("app", app); this.AddToPayload("device", device); this.AddToPayload("metaData", Metadata); this.AddToPayload("breadcrumbs", breadcrumbs); this.AddToPayload("session", session); if (session != null) { if (handledState.Handled) { session.Events.IncrementHandledCount(); } else { session.Events.IncrementUnhandledCount(); } } this.AddToPayload("user", user); }
internal Exception(string errorClass, string message, StackTraceLine[] stackTrace, HandledState handledState) { this.AddToPayload("errorClass", errorClass); this.AddToPayload("message", message); this.AddToPayload("stacktrace", stackTrace); HandledState = handledState; }
public static Exception FromUnityLogMessage(UnityLogMessage logMessage, System.Diagnostics.StackFrame[] stackFrames, Severity severity, bool forceUnhandled) { var match = Regex.Match(logMessage.Condition, ErrorClassMessagePattern, RegexOptions.Singleline); var lines = new StackTrace(logMessage.StackTrace).ToArray(); var handledState = forceUnhandled ? HandledState.ForUnhandledException() : HandledState.ForUnityLogMessage(severity); if (match.Success) { var errorClass = match.Groups["errorClass"].Value; var message = match.Groups["message"].Value.Trim(); if (errorClass == AndroidJavaErrorClass) { match = Regex.Match(message, ErrorClassMessagePattern, RegexOptions.Singleline); if (match.Success) { errorClass = match.Groups["errorClass"].Value; message = match.Groups["message"].Value.Trim(); lines = new StackTrace(logMessage.StackTrace, StackTraceFormat.AndroidJava).ToArray(); } handledState = HandledState.ForUnhandledException(); } return(new Exception(errorClass, message, lines, handledState)); } else { // include the type somehow in there return(new Exception($"UnityLog{logMessage.Type}", logMessage.Condition, lines, handledState)); } }
/// <summary> /// Creates a HandledState object for an error report payload where the severity for the exception was modified /// while running the middleware/callback. /// </summary> /// <param name="severity"></param> /// <param name="previousSeverity"></param> /// <returns></returns> internal static HandledState ForCallbackSpecifiedSeverity(Severity severity, HandledState previousSeverity) { return(new HandledState(previousSeverity.Handled, severity, SeverityReason.ForCallbackSpecifiedSeverity())); }