internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag)
        {
            try {
                var tags = new List <string> {
                    tag
                };

                if (reporting)
                {
                    return;
                }

                reporting = true;

                var oldReportCrashes = ReportCrashes;

                if (UnhandledErrorOccured != null && !silently)
                {
                    ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown);
                }

                // If crash reporting has been explicitly disabled, disregard this crash
                if (ReportCrashes.HasValue && !ReportCrashes.Value)
                {
                    return;
                }

                var customData = new Hashtable();
                foreach (var cd in SystemInformation.GetDescription())
                {
                    customData[cd.Title ?? ""] = cd.Description;
                }

#if ENABLE_RAYGUN
                if (raygunClient != null)
                {
                    ThreadPool.QueueUserWorkItem(delegate {
                        try {
                            raygunClient.Send(ex, tags, customData, Runtime.Version.ToString());
                        } catch {
                            // If we get here then things have gone really wrong - we can't log anything or
                            // attempt to report anything. Drop any exception that ends up here.
                        }
                    });
                }
#endif

                //ensure we don't lose the setting
                if (ReportCrashes != oldReportCrashes)
                {
                    PropertyService.SaveProperties();
                }
            } catch {
                // I don't know if we can/should try to log this. I'm going to guess that we don't want to
                // and can't safely call any LoggingService.Log methods anyway in case we'd recurse, though
                // the 'reporting' boolean should take care of that.
            } finally {
                reporting = false;
            }
        }
Example #2
0
        internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag)
        {
            var tags = new List <string> {
                tag
            };

            if (reporting)
            {
                return;
            }

            reporting = true;
            try {
                var oldReportCrashes = ReportCrashes;

                if (UnhandledErrorOccured != null && !silently)
                {
                    ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown);
                }

                // If crash reporting has been explicitly disabled, disregard this crash
                if (ReportCrashes.HasValue && !ReportCrashes.Value)
                {
                    return;
                }

                var customData = new Hashtable();
                foreach (var cd in SystemInformation.GetDescription())
                {
                    customData[cd.Title ?? ""] = cd.Description;
                }

#if ENABLE_RAYGUN
                if (raygunClient != null)
                {
                    ThreadPool.QueueUserWorkItem(delegate {
                        raygunClient.Send(ex, tags, customData, Runtime.Version.ToString());
                    });
                }
#endif

                //ensure we don't lose the setting
                if (ReportCrashes != oldReportCrashes)
                {
                    PropertyService.SaveProperties();
                }
            } finally {
                reporting = false;
            }
        }