當前位置: 首頁>>代碼示例>>C#>>正文


C# Exception.IsNull方法代碼示例

本文整理匯總了C#中System.Exception.IsNull方法的典型用法代碼示例。如果您正苦於以下問題:C# Exception.IsNull方法的具體用法?C# Exception.IsNull怎麽用?C# Exception.IsNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Exception的用法示例。


在下文中一共展示了Exception.IsNull方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetError

 /// <summary>
 /// </summary>
 protected static String GetError(Exception ex, Error? error = null)
 {
     if (ex.IsNull())
         return Format(error: error);
     if (!ex.InnerException.IsNull())
         return Format(ex.InnerException.Message, error);
     return Format(ex.Message, error);
 }
開發者ID:rafaelberrocalj,項目名稱:CSharpLess,代碼行數:10,代碼來源:_Exception.cs

示例2: Log

 public override ILOGGER Log(LEVEL level, string message, Exception ex = null) {
     return this.Fluently(_ => {
         var type = Mapping[level];
         ex
             .IsNull()
             .IfTrue(() => Diagnostics.Log(type, message))
             .IfFalse(() => Diagnostics.Log(type, ex, message));
         ;
     });
 }
開發者ID:afgbeveridge,項目名稱:Quorum,代碼行數:10,代碼來源:NLogLogger.cs

示例3: SerializeException

        static string SerializeException(Exception e, string exceptionMessage)
        {
            if (e.IsNull()) return string.Empty;

            exceptionMessage = "{0}{1}{2}\n{3}".FormatWith(exceptionMessage, exceptionMessage.IsEmpty() ? "" : "\n\n",
                                                           e.Message, e.StackTrace);

            if (e.InnerException.IsNotNull()) exceptionMessage = SerializeException(e.InnerException, exceptionMessage);

            return exceptionMessage;
        }
開發者ID:alanstevens,項目名稱:Contrive,代碼行數:11,代碼來源:ExceptionExtensions.cs

示例4: LogException

 public static void LogException(this ILogProvider provider,
                                 Exception exception)
 {
     var stackFrame = new StackFrame(1, true);
     var method = stackFrame.GetMethod();
     string memberName = null;
     if (method.IsNotNull())
     {
         memberName = method.Name;
     }
     var sourceFilePath = stackFrame.GetFileName();
     var sourceLineNumber = stackFrame.GetFileLineNumber();
     if (exception.IsNull())
     {
         throw new ArgumentNullException("exception");
     }
     InternalLogMessage(provider, exception.ToString(), Severity.Error, Verbosity.Normal, memberName, sourceFilePath, sourceLineNumber);
 }
開發者ID:RossMerr,項目名稱:azure-sdk-for-net,代碼行數:18,代碼來源:LogProviderExtensions.cs

示例5: Shutdown

        public static void Shutdown(Exception eventArgs = null)
        {
            sUtilities.RemovePidFile();
            sListener.Exit = true;
            Console.CursorVisible = true;

            if(!eventArgs.IsNull())
            {
                Log.Error("Main", sLConsole.GetString("An unhandled exception has been thrown. ({0})"), eventArgs.Message);
                sCrashDumper.CreateCrashDump(eventArgs);
            }

            var packet = new SchumixPacket();
            packet.Write<int>((int)Opcode.SMSG_CLOSE_CONNECTION);
            packet.Write<int>((int)0);
            sServerPacketHandler.SendPacketBackAllHost(packet);

            Thread.Sleep(2000);
            sRuntime.Exit();
        }
開發者ID:Schumix,項目名稱:Schumix2,代碼行數:20,代碼來源:Main.cs

示例6: _expandException

        /// <summary>
        /// 顯示詳細的出錯信息
        /// </summary>
        /// <param name="ex">Exception ex</param>
        /// <param name="offSet"></param>
        /// <param name="sb"></param>
        private static void _expandException(Exception ex, int offSet, StringBuilder sb) {
            if (ex.IsNull()) return;
            Type t = ex.GetType();
            string paddingString = "";
            if (offSet > 1) paddingString = new String(' ', offSet * 4);
            sb.AppendFormat("{0}Exception:   {1}{2}", paddingString, t.Name, Environment.NewLine);
            sb.AppendFormat("{0}Message:     {1}{2}", paddingString, ex.Message, Environment.NewLine);
            sb.AppendFormat("{0}Source:      {1}{2}", paddingString, ex.Source, Environment.NewLine);
            if (ex.StackTrace.IsNotNull()) sb.AppendFormat("{0}Stack Trace: {1}{2}", paddingString, ex.StackTrace.Trim(), Environment.NewLine);
            if (ex.TargetSite.IsNotNull()) sb.AppendFormat("{0}Method:      {1}{2}", paddingString, ex.TargetSite.Name, Environment.NewLine);
            sb.AppendFormat("{0}Native:      {1}{2}", paddingString, ex.ToString(), Environment.NewLine);
            sb.AppendFormat("{0}Data:        {1}{2}", paddingString, expandData(ex.Data, offSet), Environment.NewLine);

            //Exception baseException = ex.GetBaseException();
            //if (baseException.IsNotNull()) sb.AppendFormat("{0}Base:        {1}{2}", paddingString, ex.GetBaseException(), Environment.NewLine);

            _expandException(ex.InnerException, offSet + 1, sb);
        }
開發者ID:pczy,項目名稱:Pub.Class,代碼行數:24,代碼來源:Safe.cs

示例7: SetException

 public void SetException(Exception exception)
 {
     if (exception.IsNull()) return;
     ;
     LastException = exception;
     MyCallstackItem.ExceptionMessage = exception.Message;
     MyCallstackItem.StackTrace = exception.StackTrace;
 }
開發者ID:JonasSyrstad,項目名稱:Stardust,代碼行數:8,代碼來源:Tracer.cs

示例8: Log

 public override ILogger Log(LogLevel level, string message, Exception ex = null)
 {
     return this.Fluently(() => Console.WriteLine(level + ":" + message + (ex.IsNull() ? String.Empty : ", exception:  " + ex.ToString())));
 }
開發者ID:afgbeveridge,項目名稱:nhooked,代碼行數:4,代碼來源:ConsoleLogger.cs


注:本文中的System.Exception.IsNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。