コード例 #1
0
ファイル: Utility.cs プロジェクト: bitzhuwei/DeployManager
        public static string GetDetailedException(this Exception e, int prespace = 0)
        {
            if (e == null) { return ""; }
            var builder = new StringBuilder();
            builder.Tabspace(prespace); builder.AppendFormat("{0}:", DateTime.Now.ToString("yyyyMMdd-HHmmss")); builder.AppendLine();

            prespace += tabspaceUnit;
            builder.Tabspace(prespace); builder.AppendFormat("Message: {0}", e.Message); builder.AppendLine();

            builder.Tabspace(prespace); builder.AppendFormat("Source: {0}", e.Source); builder.AppendLine();

            builder.Tabspace(prespace); builder.AppendFormat("Target Site: {0}", e.TargetSite); builder.AppendLine();

            builder.Tabspace(prespace); builder.AppendFormat("Stack trace: {0}", e.StackTrace); builder.AppendLine();

            GetDetailedExceptionData(e, prespace, builder);

            builder.Tabspace(prespace); builder.AppendFormat("Help link: {0}", e.HelpLink); builder.AppendLine();

            if (e.InnerException != null)
            {
                builder.Append(e.InnerException.GetDetailedException(prespace));
            }
            prespace -= tabspaceUnit;

            return builder.ToString();
        }
コード例 #2
0
ファイル: Utility.cs プロジェクト: bitzhuwei/DeployManager
        private static void GetDetailedExceptionData(Exception e, int tabspace, StringBuilder builder)
        {
            builder.Tabspace(tabspace); builder.AppendFormat("Data:"); builder.AppendLine();

            tabspace += tabspaceUnit;
            foreach (var item in e.Data)
            {
                var entry = (DictionaryEntry)item;
                builder.Tabspace(tabspace); builder.AppendFormat("{0}:{1}", entry.Key, entry.Value); builder.AppendLine();
            }
            tabspace -= tabspaceUnit;
        }