コード例 #1
0
        internal static string GetFullString(IHaRpcServerBaseException ex, IHaRpcServerBaseExceptionInternal exInternal)
        {
            StringBuilder stringBuilder = new StringBuilder(2048);

            stringBuilder.AppendFormat("{0}: {1}", ex.GetType(), exInternal.MessageInternal);
            if (ex.InnerException != null)
            {
                stringBuilder.Append(" ---> ");
                stringBuilder.Append(ex.InnerException.ToString());
                stringBuilder.AppendLine();
                stringBuilder.Append(string.Format("   --- End of inner exception stack trace ({0}) ---", ex.InnerException.GetType()));
            }
            if (!string.IsNullOrEmpty(ex.OriginatingStackTrace))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append(ex.OriginatingStackTrace);
            }
            if (!string.IsNullOrEmpty(ex.OriginatingServer))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append(string.Format("   --- End of stack trace on server ({0}) ---", ex.OriginatingServer));
            }
            if (!string.IsNullOrEmpty(ex.StackTrace))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append(ex.StackTrace);
            }
            return(stringBuilder.ToString());
        }
コード例 #2
0
        internal static string GetCompleteExceptionMessage(Exception ex, bool fCalledFromToString)
        {
            StringBuilder stringBuilder = new StringBuilder(1024);
            bool          flag          = false;

            while (ex != null)
            {
                if (flag)
                {
                    stringBuilder.Append(" ---> ");
                }
                else
                {
                    flag = true;
                }
                string text = string.Empty;
                IHaRpcServerBaseExceptionInternal haRpcServerBaseExceptionInternal = ex as IHaRpcServerBaseExceptionInternal;
                if (haRpcServerBaseExceptionInternal != null)
                {
                    text = haRpcServerBaseExceptionInternal.MessageInternal;
                }
                else
                {
                    text = ex.Message;
                }
                if (fCalledFromToString)
                {
                    stringBuilder.AppendFormat("{0}: {1}", ex.GetType(), text);
                }
                else
                {
                    stringBuilder.Append(text);
                }
                ex = ex.InnerException;
            }
            return(stringBuilder.ToString());
        }