Exemple #1
0
        //============================================================
        // <T>获得例外对象的消息内容。</T>
        //
        // @param message 消息内容
        // @param exception 例外对象
        //============================================================
        public static void MakeMessage(FString message, Exception exception)
        {
            // 建立例外堆栈
            FObjects <Exception> stack = new FObjects <Exception>();
            Exception            find  = exception;

            while (find != null)
            {
                stack.Push(find);
                if (find is FException)
                {
                    find = ((FException)find).Reason;
                }
                else
                {
                    find = find.InnerException;
                }
            }
            // 加入消息内容
            stack.Reverse();
            message.AppendLine("Exception has raised. (@.@)");
            foreach (Exception exp in stack)
            {
                message.AppendLine(RDump.LINE_L2);
                string msg = exp.Message;
                if (!RString.IsBlank(msg))
                {
                    message.AppendLine(msg);
                }
                message.AppendLine(exp.StackTrace);
            }
        }