Beispiel #1
0
 private static LogInfo Format(string msg, Exception ex = null)
 {
     var f = new StackFrame(6, true);
     var method = f.GetMethod();
     var fileInfo = string.Format("{0}[{1}]", f.GetFileName(), f.GetFileLineNumber());
     if (ex != null)
     {
         method = ex.TargetSite;
     }
     var result = new LogInfo
     {
         Method = string.Format("{0} {1}",
             method.DeclaringType,
             method.Name),
         Message = msg,
         File = string.Empty,
         Detail = string.Empty
     };
     result.File = fileInfo;
     if (ex != null)
     {
         result.Detail = ex.Format();
     }
     return result;
 }
        static void HandleEx(Exception ex) {
            MainLog.Logger.Fatal(ex.Format(), LogLevel.Fatal);
            MessageBox.Show(
                "Info: " + ex.Message + "\n\n"
                +
                "The application will exit now. We've been notified about the problem. Sorry for the inconvenience\n\nIf the problem persists, please contact Support: http://community.withsix.com",
                "Unrecoverable error occurred");

            Environment.Exit(1);
        }
        /// <summary>
        /// Logs exception to error log
        /// </summary>
        /// <param name="exception"></param>
        static public void WriteError(Exception exception)
        {
            if (exception == null)
                return;

            Trace.TraceError(
                Environment.NewLine +
                String.Format("Date: {0:d} {0:T}", DateTime.Now) +
                Environment.NewLine +
                exception.Format());
        }
		public void Error(Exception exception)
		{
			var lines =
				new[]
					{
						"========================================================",
						string.Format("WriteLog error at {0}", DateTime.Now.FullTime()),
						exception.Format()
					};

			File.AppendAllLines(Path.Combine(folder, "Log.Exceptions.txt"), lines);
		}
Beispiel #5
0
        private static void Error(Exception ex, int exitCode) {
            var formatted = ex.Format();
            Console.Error.WriteLine(
#if DEBUG
                formatted
#else
                ex.Message
#endif
            );
            MainLog.Logger.Error(formatted);
            Environment.Exit(exitCode);
        }
Beispiel #6
0
        public void FatalException(Exception e, string message = null) {
            if (message != null)
                e = ExceptionExtensions.HandledException(e, message);

            MainLog.Logger.FormattedErrorException(e, message);
            System.Console.WriteLine(e.Format());

            if (!Common.Flags.Merged)
                return;

            ExceptionReporting.Report(e);
        }
 protected override void OnError(TransferSpec spec, Exception e) {
     if (e is OperationCanceledException) {
         this.Logger()
             .Warn(
                 $"Cancelled download of {spec.Uri} to {spec.LocalFile}, try {spec.Progress.Tries} ({e.Message})");
         return;
     }
     var msg =
         $"Failed download of {spec.Uri} to {spec.LocalFile}, try {spec.Progress.Tries} ({e.Message})\nOutput: {spec.Progress.Output}\n\nError report: {e.Format(1)}";
     if (spec.Progress.Tries > 1)
         this.Logger().Warn(msg);
     else
         this.Logger().Error(msg);
 }
Beispiel #8
0
		public void Error(Exception exception)
		{
			mainViewModel.LogError(exception.Format(), DateTime.Now);
		}
 public async Task<bool> ExceptionDialog(Exception e, string message, string title = null, object window = null) {
     await _api.ShowMessageBox(title, message + "\n" + e.Format(), null, "error").ConfigureAwait(false);
     return true;
 }
Beispiel #10
0
		public void Error(Exception exception)
		{
			Application.Current.Sync()
				.Execute(() => DialogService.DialogService.ShowMessage("Error", exception.Format(), MessageBoxButton.OK, MessageBoxImage.Error));
		}
Beispiel #11
0
 static string FormatMessage(Exception e, string message) {
     if (string.IsNullOrWhiteSpace(message))
         return e.Format();
     return message + ": " + e.Format();
 }
Beispiel #12
0
		public void Failed(Exception exception)
		{
			HasErrors = true;

			Append("Error before start {0}, message: {1}", operationName, exception.Format());
		}
Beispiel #13
0
		public void Failed(string databaseName, Exception exception)
		{
			HasErrors = true;

			Append("Database failed {0}, at time: {1}. {2}", databaseName, FullTime(), exception.Format());
		}
 protected override void OnError(TransferSpec spec, Exception e) {
     this.Logger()
         .Error("Failed download of {0} to {1}, try {2} ({3})\nOutput: {4}\n\nError report: {5}", spec.Uri,
             spec.LocalFile, spec.Progress.Tries, e.Message, spec.Progress.Output, e.Format(1));
 }
        static bool ShowExceptionDialog(string message, string title, Exception e, object window = null) {
            message = new XmlSanitizer().SanitizeXmlString(message);

            var ev = new ExceptionDialogViewModel(e.Format()) {
                Message = message,
                Title = title,
                Exception = e
            };

            var w = new ExceptionDialogView {DataContext = ev};
            if (window == null)
                DialogHelper.SetMainWindowOwner(w);
            else
                w.Owner = (Window) window;
            w.ShowDialog();

            if (ev.Throw)
                throw new ExceptionDialogThrownException("Redirected exception", e);

            return ev.Cancel;
        }