Ejemplo n.º 1
0
        static void RaiseCrashedEvent(CrashEventArgs e)
        {
            var h = Crashed;

            if (h != null)
            {
                h(null, e);
            }
        }
Ejemplo n.º 2
0
        void HandleMonitorCrashDetected(object sender, CrashEventArgs e)
        {
            InvokeOnMainThread(() => {
                try {
                    ProcessingCrashLog = true;
                    Reporter.UploadOrCache(e.CrashLogPath);

                    if (ShouldExit)
                    {
                        NSApplication.SharedApplication.Terminate(this);
                    }
                } finally {
                    ProcessingCrashLog = false;
                }
            });
        }
Ejemplo n.º 3
0
		private async void OnCartridgeCrashed(object sender, CrashEventArgs e)
		{
			string error = string.Empty;

			Regex regex = new Regex(@".*lua:(\d+):(.*)");
			Match match = regex.Match(e.ExceptionObject.InnerException.Message);

			if (match.Success)
			{
				error = string.Format(Catalog.GetString("Line {0}: {1}"), match.Groups[1].Value, match.Groups[2].Value.Trim());
			}
			else
			{
				error = e.ExceptionObject.InnerException.Message;
			}

			string message = string.Format(Catalog.GetString("You encountered an Lua error in the cartridge '{0}'.", "Part of the error message"), this.Cartridge.Name);
			message += System.Environment.NewLine;
			message += System.Environment.NewLine;
			message += error;
			message += System.Environment.NewLine;
			message += System.Environment.NewLine;
			message += Catalog.GetString("Please make a screenshot and send it to the cartridge author.", "Part of the error message");
			message += System.Environment.NewLine;
			message += System.Environment.NewLine;
			message += Catalog.GetString("The cartridge now stops.", "Part of the error message");

			// Display alert message
			await UserDialogs.Instance.AlertAsync(message, Catalog.GetString("Lua error"));

			// Close log file
			this.DestroyEngine();

			// Leave game
			App.GameNavigation.CurrentPage.Navigation.PopModalAsync();
		}
Ejemplo n.º 4
0
        const int MinCrashReportInterval       = 61;           // minimum interval between submitting crash reports, in seconds


        public static void LogAndReportCrash(string message, string assembly, Exception exception, bool shutdownImminent)
        {
            if (message == null)
            {
                message = "(null)";
            }
            if (assembly == null)
            {
                assembly = "(null)";
            }
            if (exception == null)
            {
                exception = new Exception("(null)");
            }

            Log("{0}: {1}", LogType.SeriousError, message, exception);

            bool submitCrashReport = ConfigKey.SubmitCrashReports.GetBool();
            bool isCommon          = CheckForCommonErrors(exception);

            try {
                CrashEventArgs eventArgs = new CrashEventArgs(message, assembly, exception, submitCrashReport && !isCommon, isCommon, shutdownImminent);
                RaiseCrashedEvent(eventArgs);
                isCommon = eventArgs.IsCommonProblem;
            } catch { }

            if (!submitCrashReport || isCommon)
            {
                return;
            }

            lock ( CrashReportLock ) {
                if (DateTime.UtcNow.Subtract(lastCrashReport).TotalSeconds < MinCrashReportInterval)
                {
                    Log("Logger.SubmitCrashReport: Could not submit crash report, reports too frequent.", LogType.Warning);
                    return;
                }
                lastCrashReport = DateTime.UtcNow;

                try {
                    StringBuilder sb = new StringBuilder();
                    sb.Append("version=").Append(Uri.EscapeDataString(Updater.CurrentRelease.VersionString));
                    sb.Append("&message=").Append(Uri.EscapeDataString(message));
                    sb.Append("&assembly=").Append(Uri.EscapeDataString(assembly));
                    sb.Append("&runtime=");
                    if (MonoCompat.IsMono)
                    {
                        sb.Append(Uri.EscapeDataString("Mono " + MonoCompat.MonoVersionString));
                    }
                    else
                    {
                        sb.Append(Uri.EscapeDataString("CLR " + Environment.Version));
                    }
                    sb.Append("&os=").Append(Environment.OSVersion.Platform + " / " + Environment.OSVersion.VersionString);

                    if (exception is TargetInvocationException)
                    {
                        exception = (exception).InnerException;
                    }
                    else if (exception is TypeInitializationException)
                    {
                        exception = (exception).InnerException;
                    }
                    sb.Append("&exceptiontype=").Append(Uri.EscapeDataString(exception.GetType().ToString()));
                    sb.Append("&exceptionmessage=").Append(Uri.EscapeDataString(exception.Message));
                    sb.Append("&exceptionstacktrace=").Append(Uri.EscapeDataString(exception.StackTrace));

                    if (File.Exists(Paths.ConfigFileName))
                    {
                        sb.Append("&config=").Append(Uri.EscapeDataString(File.ReadAllText(Paths.ConfigFileName)));
                    }
                    else
                    {
                        sb.Append("&config=");
                    }

                    string[] lastFewLines;
                    lock ( LogLock ) {
                        lastFewLines = RecentMessages.ToArray();
                    }
                    sb.Append("&log=").Append(Uri.EscapeDataString(String.Join(Environment.NewLine, lastFewLines)));

                    byte[] formData = Encoding.ASCII.GetBytes(sb.ToString());

                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(CrashReportUrl);
                    ServicePointManager.Expect100Continue = false;
                    request.Method        = "POST";
                    request.Timeout       = 15000; // 15s timeout
                    request.ContentType   = "application/x-www-form-urlencoded";
                    request.CachePolicy   = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                    request.ContentLength = formData.Length;

                    using (Stream requestStream = request.GetRequestStream()) {
                        requestStream.Write(formData, 0, formData.Length);
                        requestStream.Flush();
                    }

                    request.Abort();
                    Log("Crash report submitted.", LogType.SystemActivity);
                } catch (Exception ex) {
                    Log("Logger.SubmitCrashReport: {0}", LogType.Warning, ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
 private void Core_CartridgeCrashed(object sender, CrashEventArgs e)
 {
     // Displays a message, resets the core and goes back to app home.
     HandleGameCrash(CrashMessageType.Runtime, e.ExceptionObject, e.Cartridge);
 }
Ejemplo n.º 6
0
		private void Core_CartridgeCrashed(object sender, CrashEventArgs e)
		{
			// Displays a message, resets the core and goes back to app home.
			HandleGameCrash(CrashMessageType.Runtime, e.ExceptionObject, e.Cartridge);
		}