Beispiel #1
0
        /// <summary>
        /// Report the specified message and an associated inner exception to the app center error tracker.
        /// </summary>
        /// <returns>The report.</returns>
        /// <param name="message">Message.</param>
        /// <param name="innerException">Inner exception.</param>
        public static SensusException Report(string message, Exception innerException = null)
        {
            // the service helper isn't always initialized (e.g., upon startup), so make sure to catch any exceptions.
            string deviceId = null;

            try
            {
                SensusServiceHelper.Get().Logger.Log("Reporting Sensus exception:  " + message, LoggingLevel.Normal, typeof(SensusException));
                deviceId = SensusServiceHelper.Get().DeviceId;
            }
            catch (Exception)
            { }

            SensusException exceptionToReport = null;

            try
            {
                exceptionToReport = new SensusException("Device " + (deviceId ?? "[no ID]") + ":  " + message, innerException);
                Crashes.TrackError(exceptionToReport);
            }
            catch (Exception ex)
            {
                try
                {
                    SensusServiceHelper.Get().Logger.Log("Failed to report exception:  " + ex.Message, LoggingLevel.Normal, typeof(SensusException));
                }
                catch (Exception)
                { }
            }

            return(exceptionToReport);
        }
Beispiel #2
0
        public static void Report(string message, Exception innerException = null, bool throwException = false)
        {
            SensusException exception = new SensusException(message, innerException);

            if (throwException)
            {
                throw exception;
            }
        }
Beispiel #3
0
        public static SensusException Report(string message, Exception innerException = null)
        {
            SensusServiceHelper.Get().Logger.Log("Sensus exception being reported:  " + message + Environment.NewLine + "Stack:  " + Environment.StackTrace, LoggingLevel.Normal, typeof(SensusException));

            SensusException sensusException = new SensusException(message, innerException);

            try
            {
                Insights.Report(sensusException, "Stack Trace", Environment.StackTrace, Insights.Severity.Critical);
            }
            catch (Exception ex)
            {
                SensusServiceHelper.Get().Logger.Log("Failed to report new exception to Xamarin Insights:  " + ex.Message, LoggingLevel.Normal, typeof(SensusException));
            }

            return(sensusException);
        }