Example #1
0
        /// <summary>
        /// Record an application exception, along with a message.
        /// </summary>
        /// <param name="message">The message to record along with the exception.</param>
        /// <param name="exception">The exception to record.</param>
        public static void LogError(string message, System.Exception exception)
        {
#if __IOS__
            NativeFlurry.LogError(
                string.Format(exception.GetType().FullName, message),
                exception.ToString(),
                new NSException(exception.GetType().FullName, exception.Message, null));
#elif __ANDROID__
            Java.Lang.Exception javaEx     = new Java.Lang.Exception(exception.Message);
            StackTrace          stackTrace = new StackTrace(exception, true);
            StackTraceElement[] trace      = new StackTraceElement[stackTrace.FrameCount];
            for (int index = 0; index < stackTrace.FrameCount; ++index)
            {
                StackFrame frame = stackTrace.GetFrame(index);
                trace[index] = new StackTraceElement(frame.GetMethod().DeclaringType.Name, frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
            }
            javaEx.SetStackTrace(trace);
            NativeFlurry.OnError(
                string.Format(exception.GetType().FullName, message),
                exception.ToString(),
                javaEx);
#elif WINDOWS_PHONE
            NativeFlurry.LogError(message, exception);
#endif
        }
        public static Java.Lang.Exception GetJavaException(this System.Exception e)
        {
            var javaException = new Java.Lang.Exception(e.Message);

            javaException.SetStackTrace(GetTraceFromMonoException(e));

            if (e.InnerException != null)
            {
                javaException.InitCause(e.InnerException.GetJavaException());
            }

            return(javaException);
        }
		/// <summary>
		/// Record an application exception, along with a message.
		/// </summary>
		/// <param name="message">The message to record along with the exception.</param>
		/// <param name="exception">The exception to record.</param>
		public static void LogError(string message, System.Exception exception)
		{
#if __IOS__
			NativeFlurry.LogError(
				string.Format(exception.GetType().FullName, message), 
				exception.ToString(),
				new NSException (exception.GetType().FullName, exception.Message, null));
#elif __ANDROID__
			Java.Lang.Exception javaEx = new Java.Lang.Exception(exception.Message);
			StackTrace stackTrace = new StackTrace(exception, true);
			StackTraceElement[] trace = new StackTraceElement[stackTrace.FrameCount];
			for (int index = 0; index < stackTrace.FrameCount; ++index)
			{
				StackFrame frame = stackTrace.GetFrame(index);
				trace[index] = new StackTraceElement(frame.GetMethod().DeclaringType.Name, frame.GetMethod().Name, frame.GetFileName(), frame.GetFileLineNumber());
			}
			javaEx.SetStackTrace(trace);
			NativeFlurry.OnError(
				string.Format(exception.GetType().FullName, message),
				exception.ToString(),
				javaEx);
#elif WINDOWS_PHONE
			NativeFlurry.LogError(message, exception);
#endif
		}