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


C# Exception.ToString方法代码示例

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


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

示例1: Handle

 public string Handle(Exception exc)
 {
     if (!QPP.Wpf.UI.Util.IsDesignMode)
     {
         if (exc is ValidationException)
         {
             RuntimeContext.Service.GetObject<IDialog>().Show(new DialogMessage()
             {
                 Content = exc.Message
             });
         }
         //else if (exc is System.Security.Authentication.AuthenticationException)
         //{
         //    //Messenger.Default.Send(LoginMessage.Instance);
         //}
         else
         {
             RuntimeContext.Service.Trace.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss ")
                 + RuntimeContext.Service.L10N.GetText("發生錯誤:") + exc.ToString() + Environment.NewLine);
             RuntimeContext.Service.GetObject<IDialog>().Show(new DialogMessage()
             {
                 Content = exc.ToString()
             });
         }
     }
     return exc.Message;
 }
开发者ID:eolandezhang,项目名称:Diagram,代码行数:27,代码来源:ExceptionHandler.cs

示例2: Compare

        /// <summary>
        /// Compares the ClientExpectedException to the provided exception and verifies the exception is correct
        /// </summary>
        /// <param name="expectedClientException">Expected Client Exception</param>
        /// <param name="exception">Actual Exception</param>
        public void Compare(ExpectedClientErrorBaseline expectedClientException, Exception exception)
        {
            ExceptionUtilities.CheckAllRequiredDependencies(this);

            if (expectedClientException == null)
            {
                string exceptionMessage = null;
                if (exception != null)
                {
                    exceptionMessage = exception.ToString();
                }

                this.Assert.IsNull(exception, "Expected to not recieve an exception:" + exceptionMessage);
                return;
            }

            this.Assert.IsNotNull(exception, "Expected Exception to not be null");
            this.Assert.AreEqual(expectedClientException.ExpectedExceptionType, exception.GetType(), string.Format(CultureInfo.InvariantCulture, "ExceptionType is not equal, receieved the following exception: {0}", exception.ToString()));
            
            if (expectedClientException.HasServerSpecificExpectedMessage)
            {
                if (this.ShouldVerifyServerMessageInClientException)
                {
                    this.Assert.IsNotNull(exception.InnerException, "Expected Inner Exception to contain ODataError");
                    byte[] byteArrPayload = HttpUtilities.DefaultEncoding.GetBytes(exception.InnerException.Message);
                    ODataErrorPayload errorPayload = this.ProtocolFormatStrategySelector.DeserializeAndCast<ODataErrorPayload>(null, MimeTypes.ApplicationXml, byteArrPayload);

                    expectedClientException.ExpectedExceptionMessage.VerifyMatch(this.systemDataServicesVerifier, errorPayload.Message, true);
                }   
            }
            else
            {
                expectedClientException.ExpectedExceptionMessage.VerifyMatch(this.systemDataServicesClientVerifier, exception.Message, true);
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:40,代码来源:ClientExpectedErrorComparer.cs

示例3: Failed

 public void Failed(IExample example, Exception exception)
 {
     LastResult = TaskResult.Exception;
     _server.TaskOutput(CurrentTask, "Failed:", TaskOutputType.STDERR);
     _server.TaskOutput(CurrentTask, exception.ToString(), TaskOutputType.STDERR);
     _server.TaskFinished(CurrentTask, exception.ToString(), TaskResult.Exception);
 }
开发者ID:davidmfoley,项目名称:bickle,代码行数:7,代码来源:ReSharperListener.cs

示例4: WriteException

 internal static void WriteException(Exception e)
 {
   WriteLine(e.ToString());
   WriteLine(e.InnerException?.ToString());
   Console.WriteLine(e.ToString());
   Console.WriteLine(e.InnerException?.ToString());
 }
开发者ID:gitter-badger,项目名称:CodeLinker,代码行数:7,代码来源:Log.cs

示例5: AnalyzeException

        public static bool AnalyzeException(Exception exception)
        {
            //if (exception is System.NullReferenceException && exception.ToString().Contains("JsMinifier"))
            //    return true;

            if (exception is System.Web.HttpException)
            {
                if (exception.ToString().Contains("ComponentNotFoundException"))
                    return true;

                if (exception.ToString().Contains("A potentially dangerous Request.Path"))
                    return true;
            }

            var ret = exception.Message.Contains("php")
                   || exception.Message.Contains(".gif")
                   || exception.Message.Contains(".jpg")
                   || exception.Message.Contains(".png")
                // args.Exception.Message.Contains("Castle.MicroKernel.ComponentNotFoundException") ||
                   || exception is Castle.MicroKernel.ComponentNotFoundException
                   //|| exception.Message.ToLower().Contains("jsminifier")
                   || exception.Message.ToLower().Contains("cultureFilter")
                   //|| exception.Message.ToLower().Contains("abs.globalize.en.js")
                ;

            return ret;
        }
开发者ID:avannini,项目名称:uisp-mobile,代码行数:27,代码来源:ExceptionFilterHelper.cs

示例6: PrintError

        public static int PrintError(Exception ex)
        {
            if (ex is CommandException)
            {
                Log.Error(ex.Message);
                return 1;
            }
            if (ex is ReflectionTypeLoadException)
            {
                Log.Error(ex.ToString());

                foreach (var loaderException in ((ReflectionTypeLoadException)ex).LoaderExceptions)
                {
                    Log.Error(loaderException.ToString());

                    if (!(loaderException is FileNotFoundException))
                        continue;

                    var exFileNotFound = loaderException as FileNotFoundException;
                    if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                    {
                        Log.Error(exFileNotFound.FusionLog);
                    }
                }

                return 43;
            }

            Log.Error(ex.ToString());
            return 100;
        }
开发者ID:bjewell52,项目名称:Calamari,代码行数:31,代码来源:ConsoleFormatter.cs

示例7: DisplayableExceptionDisplayForm

        /// <summary>
        /// Initialize w/ required values
        /// </summary>
        public DisplayableExceptionDisplayForm(Exception exception)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.labelMessage.Font = Res.GetFont(FontSize.Large, FontStyle.Bold);
            this.buttonOK.Text = Res.Get(StringId.OKButtonText);

            // initialize controls
            Icon = ApplicationEnvironment.ProductIcon;
            pictureBoxIcon.Image = errorBitmap;

            DisplayableException displayableException = exception as DisplayableException;
            if (displayableException != null)
            {
                Text = EnsureStringValueProvided(displayableException.Title);
                labelMessage.Text = EnsureStringValueProvided(displayableException.Title);
                textBoxDetails.Text = EnsureStringValueProvided(displayableException.Text);

                // log the error
                Trace.WriteLine(String.Format(CultureInfo.InvariantCulture, "DisplayableException occurred: {0}", displayableException.ToString()));
            }
            else
            {
                // log error
                Trace.WriteLine("Non DisplayableException-derived exception thrown. Subsystems need to handle these exceptions and convert them to WriterExceptions:\r\n" + exception.ToString());

                // give the user a full data dump
                Text = Res.Get(StringId.UnexpectedErrorTitle);
                labelMessage.Text = exception.GetType().Name;
                textBoxDetails.Text = exception.ToString();
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:38,代码来源:DisplayableExceptionDisplayForm.cs

示例8: ShowError

		/// <summary>
		/// Dislays a <see cref="MessageBox"/> indication an exception.
		/// </summary>
		/// <param name="value">The screen to show the <see cref="MessageBox"/> on.</param>
		/// <param name="ex">The exception to display.</param>
		public static void ShowError(this IScreenObject value, Exception ex)
		{
#if DEBUG
			Debug.WriteLine(ex.ToString());
#endif
			value.ShowMessageBox(ex.ToString(), "Fehler", Microsoft.LightSwitch.Presentation.Extensions.MessageBoxOption.Ok);
		}
开发者ID:Richment,项目名称:Cash-Application,代码行数:12,代码来源:Helper.cs

示例9: LogException

        public static void LogException(Exception exception)
        {
            if (exception != null)
            {
                Debug.Print(exception.ToString());
                Logger.Error(exception.ToString());

                try
                {
                    var error = new VLogServerSideError(exception);

                    VLogErrorCode weberrorcode = VLog.GetWebErrorCodeOrDefault(error.ErrorCode, VLogErrorTypes.ServerSideIIS);

                    if (weberrorcode != null && !weberrorcode.ExcludeFromLogging)
                    {
                        if (VLog.OnCommitExceptionToServerRepository != null)
                        {
                            VLog.OnCommitExceptionToServerRepository(error);
                        }
                    }
                }
                catch (Exception ex)
                {
                    // IMPORTANT! We swallow any exception raised during the
                    // logging and send them out to the trace . The idea
                    // here is that logging of exceptions by itself should not
                    // be  critical to the overall operation of the application.
                    // The bad thing is that we catch ANY kind of exception,
                    // even system ones and potentially let them slip by.
                    Logger.Error(ex.ToString());
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }
        }
开发者ID:MGramolini,项目名称:vodca,代码行数:34,代码来源:VLog.LogException.cs

示例10: AnomalyShow

 private void AnomalyShow(Exception exc)
 {
     LogMessage(exc.ToString());
     if (DetectorsAccess.Logger != null)
         DetectorsAccess.Logger.LogError(Utilities.TextTidy(exc.ToString()));
     MessageBox.Show(Utilities.TextTidy(exc.ToString()), "Anomaly!", MessageBoxButton.OK, MessageBoxImage.Error);
 }
开发者ID:BdGL3,项目名称:CXPortal,代码行数:7,代码来源:TestNCB.xaml.cs

示例11: SetupGeneric

		public void SetupGeneric(Exception exception)
		{
			try
			{
				this.Text = "Error";
				this.splitter1.Visible = false;
				this.panel3.Dock = DockStyle.None;
				this.panel3.Visible = false;
				this.panel1.Dock = DockStyle.Fill;
				this.panel1.BringToFront();
				var errorText = exception.ToString();
				if (exception is InvalidSQLException)
					errorText = "FileName: '" + ((InvalidSQLException)exception).FileName + "'" + errorText;

				UpgradeInstaller.LogError(exception.InnerException, "[ERROR]\r\n" + errorText);
				if (exception.InnerException != null)
					txtError.Text = exception.InnerException.ToString();
				else
					txtError.Text = exception.ToString();
				cmdSkip.Visible = false;
			}
			catch (Exception ex)
			{
				//Do Nothing
			}
		}
开发者ID:nHydrate,项目名称:nHydrate,代码行数:26,代码来源:SqlErrorForm.cs

示例12: Error

        static void Error(Exception ex)
        {
            if (File.Exists(ConfigurationManager.AppSettings["Error"]) == true)
            {
                File.Delete(ConfigurationManager.AppSettings["Error"]);
            }

            using (FileStream file = File.Create(ConfigurationManager.AppSettings["Error"]))
            {
                using (StreamWriter sw = new StreamWriter(file))
                {
                    if (ex.GetType() == typeof(WebException))
                    {
                        sw.Write(((WebException)ex).ToString());
                        System.Console.WriteLine(((WebException)ex).ToString());
                    }
                    else
                    {
                        sw.Write(ex.ToString());
                        System.Console.WriteLine(ex.ToString());
                    }
                    sw.Close();
                }
                file.Close();

            }
        }
开发者ID:A51UK,项目名称:Shopify_Product_UpLoader,代码行数:27,代码来源:Program.cs

示例13: DllImportError

 /// <summary>
 /// DllImportの際にDllNotFoundExceptionかBadImageFormatExceptionが発生した際に呼び出されるメソッド。
 /// エラーメッセージを表示して解決策をユーザに示す。
 /// </summary>
 /// <param name="e"></param>
 public static void DllImportError(Exception e)
 {
     string nl = Environment.NewLine;
     if (System.Globalization.CultureInfo.CurrentCulture.Name.Contains("ja"))
     {
         MessageBox.Show(
             "P/Invokeが原因で例外が発生しました。" + nl + "以下の項目を確認して下さい。" + nl + nl +
             "1. OpenCVのDLLが実行ファイルと同じ場所に置かれていますか? またはパスが正しく通っていますか?" + nl +
             "2. Visual C++ Redistributable Packageをインストールしましたか?" + nl +
             "3. OpenCVのDLLやOpenCvSharpの対象プラットフォーム(x86またはx64)と、プロジェクトのプラットフォーム設定が合っていますか?" + nl + nl +
             e.ToString(),
             "OpenCvSharp Error",
             MessageBoxButtons.OK, MessageBoxIcon.Error
         );
     }
     else
     {
         MessageBox.Show(
             "An exception has occurred because of P/Invoke." + nl + "Please check the following:" + nl + nl +
             "1. OpenCV's DLL files exist in the same directory as the executable file." + nl +
             "2. Visual C++ Redistributable Package has been installed." + nl +
             "3. The target platform(x86/x64) of OpenCV's DLL files and OpenCvSharp is the same as your project's." + nl + nl +
             e.ToString(),
             "OpenCvSharp Error",
             MessageBoxButtons.OK, MessageBoxIcon.Error
         );
     }
 }
开发者ID:qxp1011,项目名称:opencvsharp,代码行数:33,代码来源:PInvokeHelper.cs

示例14: GetClientException

        public static Exception GetClientException(Exception exp, string MethodName)
        {
            Exception e;
            String str=null;
            if (exp is FaultException)
            {
                WriteException(exp.ToString(), str);
                return exp;
            }
            if (exp is CommunicationException)
            {

                WriteException(exp.ToString(), str);
                return exp;
            }
            if (exp is EndpointNotFoundException)
            {

                WriteException(exp.ToString(), str);
            }

            else {

                WriteException(exp.ToString(), str);

              //  Exception GenException = new GenericException(exp.Message, exp);
            }
            return null;
        }
开发者ID:Yelena11,项目名称:Refactored_App,代码行数:29,代码来源:WCFFaultException.cs

示例15: WriteLine

 public static void WriteLine(string text, Exception ex = null, int logLevel = 4)
 {
     string content = text;
     if (ex != null)
         content += ex.ToString();
     if (Convert.ToBoolean(ConfigurationManager.AppSettings["consoleDebug"]))
     {
         Console.WriteLine(content);
     }
     else
     {
     }
     if(logLevel <= m_vLogLevel)
     {
         lock (m_vSyncObject)
         {
             m_vTextWriter.Write(DateTime.Now.ToString("yyyy/MM/dd/HH/mm/ss"));
             m_vTextWriter.Write("\t");
             m_vTextWriter.WriteLine(content);
             if (ex != null)
                 m_vTextWriter.WriteLine(ex.ToString());
             m_vTextWriter.Flush();
         }
     }
 }
开发者ID:Caes95,项目名称:ucs,代码行数:25,代码来源:Debugger.cs


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