当前位置: 首页>>代码示例>>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;未经允许,请勿转载。