Skip to content

Commit

Permalink
Added additional client error logging when parsing exceptions.
Browse files Browse the repository at this point in the history
This should give us more insight into MSIX issues.
  • Loading branch information
niemyjski committed Oct 12, 2023
1 parent 77ad8a2 commit 672ff05
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
25 changes: 19 additions & 6 deletions src/Exceptionless/Extensions/ToErrorModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie
PropertyInfo info = type.GetProperty("HResult", BindingFlags.Public | BindingFlags.Instance);
if (info != null)
error.Code = info.GetValue(exception, null).ToString();
} catch (Exception) { }
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, "Error populating HResult Code: " + ex.Message);
}

#if NET45
try {
Expand Down Expand Up @@ -93,7 +95,9 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie
var extraProperties = type.GetPublicProperties().Where(p => !p.Name.AnyWildcardMatches(exclusions, true)).ToDictionary(p => p.Name, p => {
try {
return p.GetValue(exception, null);
} catch { }
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, String.Format("Error getting extra exception property {0} value: {1}", p.Name, ex.Message));
}
return null;
});

Expand All @@ -107,7 +111,9 @@ private static Error ToErrorModelInternal(Exception exception, ExceptionlessClie
MaxDepthToSerialize = 5
}, client);
}
} catch { }
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, "Error populating extra exception properties: " + ex.Message);
}

if (exception.InnerException != null)
error.Inner = ToErrorModelInternal(exception.InnerException, client, true);
Expand Down Expand Up @@ -164,7 +170,9 @@ internal static ModuleCollection GetLoadedModules(IExceptionlessLog log, bool in
var attrs = assembly.GetCustomAttributes(typeof(System.CodeDom.Compiler.GeneratedCodeAttribute)).ToList();
if (attrs.Count > 0)
continue;
} catch {}
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, "Error while checking if assembly " + assembly.FullName + " should be added to modules:" + ex.Message);
}
}

var module = assembly.ToModuleInfo();
Expand All @@ -185,10 +193,15 @@ private static void PopulateStackTrace(this Error error, Error root, Exception e
try {
var st = new EnhancedStackTrace(exception);
frames = st.GetFrames();
} catch {}
}
catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, "Error getting stack frames: " + ex.Message);
}

if (frames == null)
if (frames == null || frames.Length == 0) {
log.Info(typeof(ExceptionlessClient), "Error " + error.Message + " contained no stack frames");
return;
}

foreach (StackFrame frame in frames) {
var stackFrame = new Models.Data.StackFrame {
Expand Down
8 changes: 6 additions & 2 deletions src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ private static SimpleError ToSimpleErrorModelInternal(this Exception exception,
var extraProperties = type.GetPublicProperties().Where(p => !p.Name.AnyWildcardMatches(exclusions, true)).ToDictionary(p => p.Name, p => {
try {
return p.GetValue(exception, null);
} catch {}
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, String.Format("Error getting extra exception property {0} value: {1}", p.Name, ex.Message));
}
return null;
});

Expand All @@ -83,7 +85,9 @@ private static SimpleError ToSimpleErrorModelInternal(this Exception exception,
MaxDepthToSerialize = 5
}, client);
}
} catch {}
} catch (Exception ex) {
log.Error(typeof(ExceptionlessClient), ex, "Error populating extra exception properties: " + ex.Message);
}

if (exception.InnerException != null)
error.Inner = exception.InnerException.ToSimpleErrorModel(client);
Expand Down

0 comments on commit 672ff05

Please sign in to comment.