From 672ff05f1aececace028cdc01201c2a54cd77c94 Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Thu, 12 Oct 2023 08:10:03 -0500 Subject: [PATCH] Added additional client error logging when parsing exceptions. This should give us more insight into MSIX issues. --- .../Extensions/ToErrorModelExtensions.cs | 25 ++++++++++++++----- .../ToSimpleErrorModelExtensions.cs | 8 ++++-- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/Exceptionless/Extensions/ToErrorModelExtensions.cs b/src/Exceptionless/Extensions/ToErrorModelExtensions.cs index 0ac863e3..b8557997 100644 --- a/src/Exceptionless/Extensions/ToErrorModelExtensions.cs +++ b/src/Exceptionless/Extensions/ToErrorModelExtensions.cs @@ -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 { @@ -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; }); @@ -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); @@ -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(); @@ -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 { diff --git a/src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs b/src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs index 3e01b3e6..8a9e3226 100644 --- a/src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs +++ b/src/Exceptionless/Extensions/ToSimpleErrorModelExtensions.cs @@ -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; }); @@ -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);