Exemple #1
0
        internal ErrorReport(MSErrorReport msReport)
        {
            // If Id is not null we have loaded the report from the cache
            if (Id != null)
            {
                return;
            }

            Id           = msReport.IncidentIdentifier;
            AppStartTime = NSDateToDateTimeOffset(msReport.AppStartTime);
            AppErrorTime = NSDateToDateTimeOffset(msReport.AppErrorTime);
            Device       = msReport.Device == null ? null : new Device(msReport.Device);

            AndroidDetails = null;

            iOSDetails = new iOSErrorDetails(msReport.ReporterKey,
                                             msReport.Signal,
                                             msReport.ExceptionName,
                                             msReport.ExceptionReason,
                                             (uint)msReport.AppProcessIdentifier);

            MSWrapperException wrapperException = MSWrapperExceptionManager.LoadWrapperExceptionWithUUID(msReport.IncidentIdentifier);

            if (wrapperException != null && wrapperException.ExceptionData != null)
            {
                Exception = CrashesUtils.DeserializeException(wrapperException.ExceptionData.ToArray());
            }
        }
        internal ErrorReport(AndroidErrorReport androidReport)
        {
            Id           = androidReport.Id;
            AppStartTime = DateTimeOffset.FromUnixTimeMilliseconds(androidReport.AppStartTime.Time);
            AppErrorTime = DateTimeOffset.FromUnixTimeMilliseconds(androidReport.AppErrorTime.Time);
            Device       = androidReport.Device == null ? null : new Device(androidReport.Device);

            object androidThrowable;

            try
            {
                androidThrowable = androidReport.Throwable;
            }
            catch (Exception e)
            {
                MobileCenterLog.Debug(Crashes.LogTag, "Cannot read throwable from java point of view, probably a .NET exception", e);
                androidThrowable = null;
                byte[] exceptionBytes = AndroidExceptionDataManager.LoadWrapperExceptionData(Java.Util.UUID.FromString(Id));
                if (exceptionBytes != null)
                {
                    Exception = CrashesUtils.DeserializeException(exceptionBytes);
                }
            }

            AndroidDetails = new AndroidErrorDetails(androidThrowable, androidReport.ThreadName);
            iOSDetails     = null;
        }
        /// <summary>
        /// We don't assume order between java crash handler and c# crash handler.
        /// This method is called after either of those 2 events and is thus effective only the second time when we got both the c# exception and the Android error log.
        /// </summary>
        private static void JoinExceptionAndLog()
        {
            /*
             * We don't assume order between java crash handler and c# crash handler.
             * This method is called after either of those 2 events.
             * It is thus effective only the second time when we got both the .NET exception and the Android error log.
             */
            if (_errorLog != null && _exception != null)
            {
                /*
                 * Generate structured data for the C# exception and overwrite the Java exception to enhance it.
                 * Unless if we have java exception in top cause, this would make it worse.
                 * Having java exception as intermediate cause is better with .NET stack structure though.
                 */
                if (!(_exception is Java.Lang.Exception))
                {
                    _errorLog.Exception = GenerateModelException(_exception);

                    /* Tell the Android SDK to overwrite the modified error log on disk. */
                    AndroidExceptionDataManager.SaveWrapperSdkErrorLog(_errorLog);
                }

                /* Save the System.Exception to disk as a serialized object for client side inspection. */
                byte[] exceptionData = CrashesUtils.SerializeException(_exception);
                AndroidExceptionDataManager.SaveWrapperExceptionData(exceptionData, _errorLog.Id);
            }
        }
        private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   systemException = e.ExceptionObject as Exception;
            MSException exception       = GenerateiOSException(systemException);

            MSWrapperExceptionManager.SetWrapperException(exception);

            byte[] exceptionBytes       = CrashesUtils.SerializeException(systemException);
            NSData wrapperExceptionData = NSData.FromArray(exceptionBytes);

            MSWrapperExceptionManager.SetWrapperExceptionData(wrapperExceptionData);
        }
        private static void OnUnhandledException(object sender, RaiseThrowableEventArgs e)
        {
            var exception = e.Exception;

            MobileCenterLog.Error(Crashes.LogTag, "Unhandled Exception:", exception);
            if (!(exception is Java.Lang.Exception))
            {
                var    modelException = GenerateModelException(exception, true);
                byte[] rawException   = CrashesUtils.SerializeException(exception);
                WrapperSdkExceptionManager.SaveWrapperException(Thread.CurrentThread(), modelException, rawException);
            }
        }
        private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception   systemException = e.ExceptionObject as Exception;
            MSException exception       = GenerateiOSException(systemException, true);

            byte[] exceptionBytes       = CrashesUtils.SerializeException(systemException);
            NSData wrapperExceptionData = NSData.FromArray(exceptionBytes);

            MSWrapperException wrapperException = new MSWrapperException
            {
                Exception     = exception,
                ExceptionData = wrapperExceptionData,
                ProcessId     = new NSNumber(Process.GetCurrentProcess().Id)
            };

            MSWrapperExceptionManager.SaveWrapperException(wrapperException);
        }
Exemple #7
0
        /// <summary>
        /// We don't assume order between java crash handler and c# crash handler.
        /// This method is called after either of those 2 events and is thus effective only the second time when we got both the c# exception and the Android error log.
        /// </summary>
        private static void JoinExceptionAndLog()
        {
            /*
             * We don't assume order between java crash handler and c# crash handler.
             * This method is called after either of those 2 events.
             * It is thus effective only the second time when we got both the c# exception and the Android error log.
             */
            if (_errorLog != null && _exception != null)
            {
                /* Generate structured data for the C# exception and overwrite the Java exception. */
                _errorLog.Exception = GenerateModelException(_exception);

                /* Tell the Android SDK to overwrite the modified error log on disk. */
                AndroidExceptionDataManager.SaveWrapperSdkErrorLog(_errorLog);

                /* Save the System.Exception to disk as a serialized object. */
                byte[] exceptionData = CrashesUtils.SerializeException(_exception);
                AndroidExceptionDataManager.SaveWrapperExceptionData(exceptionData, _errorLog.Id);
            }
        }