当前位置: 首页>>代码示例>>C#>>正文


C# Exception.Format方法代码示例

本文整理汇总了C#中System.Exception.Format方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.Format方法的具体用法?C# Exception.Format怎么用?C# Exception.Format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Exception的用法示例。


在下文中一共展示了Exception.Format方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Format

 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;
 }
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:25,代码来源:Log4NetLog.cs

示例2: HandleEx

        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);
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:10,代码来源:ExDialog.cs

示例3: WriteError

        /// <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());
        }
开发者ID:peschuster,项目名称:propresenter-remote,代码行数:15,代码来源:Program.cs

示例4: Error

		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);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:12,代码来源:LoggerExceptions.cs

示例5: Error

        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);
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:12,代码来源:Program.cs

示例6: FatalException

        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);
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:12,代码来源:Program.cs

示例7: OnError

 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);
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:14,代码来源:LoggingFileDownloaderDecorator.cs

示例8: Error

		public void Error(Exception exception)
		{
			mainViewModel.LogError(exception.Format(), DateTime.Now);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:4,代码来源:ViewLogger.cs

示例9: ExceptionDialog

 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;
 }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:4,代码来源:NodeDialogManager.cs

示例10: Error

		public void Error(Exception exception)
		{
			Application.Current.Sync()
				.Execute(() => DialogService.DialogService.ShowMessage("Error", exception.Format(), MessageBoxButton.OK, MessageBoxImage.Error));
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:5,代码来源:DialogLogger.cs

示例11: FormatMessage

 static string FormatMessage(Exception e, string message) {
     if (string.IsNullOrWhiteSpace(message))
         return e.Format();
     return message + ": " + e.Format();
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:5,代码来源:Logger.cs

示例12: Failed

		public void Failed(Exception exception)
		{
			HasErrors = true;

			Append("Error before start {0}, message: {1}", operationName, exception.Format());
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:6,代码来源:DatabaseLogger.cs

示例13: OnError

 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));
 }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:5,代码来源:LoggingFileDownloaderDecorator.cs

示例14: ShowExceptionDialog

        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;
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:21,代码来源:WpfDialogManager.cs


注:本文中的System.Exception.Format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。