/// <summary> /// Dumps an exception to the isolated storage and on BugSense. /// </summary> /// <param name="ex"></param> /// <param name="customMessage"></param> /// <param name="dumpOnBugSenseToo"></param> public static void DumpException(Exception ex, string customMessage = null, bool dumpOnBugSenseToo = false) { // BugSense dump. if (dumpOnBugSenseToo && BugSenseHandler.IsInitialized) { BugSense.Core.Model.LimitedCrashExtraDataList extraData = null; if (customMessage != null) { extraData = new BugSense.Core.Model.LimitedCrashExtraDataList(); extraData.Add("customMessage", customMessage); } BugSenseHandler.Instance.SendExceptionAsync(ex, extraData); } // Local dump. using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) { // Ensures the folder exists. isf.CreateDirectory("/Debug"); // Gets the filename prefix. string prefix = "/Debug/" + DateTime.UtcNow.ToString("yyyyMMddHHmmssffff") + "_" + ex.GetHashCode() + "_"; // Dumps the stack trace. using (IsolatedStorageFileStream stream = isf.CreateFile(prefix + "stacktrace.txt")) { using (StreamWriter sw = new StreamWriter(stream)) { DumpException((dynamic)ex, sw, customMessage); } } } }