The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ExceptionExtensions.cs 726B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace Teknik.Helpers
  6. {
  7. public static class ExceptionExtensions
  8. {
  9. public static string GetFullMessage(this Exception ex, bool recursive = false, bool stackTrace = false)
  10. {
  11. string message = ex.Message;
  12. if (recursive && ex.InnerException != null)
  13. {
  14. message += " | Inner Exception: " + ex.InnerException.GetFullMessage(recursive, stackTrace);
  15. }
  16. if (stackTrace && !string.IsNullOrEmpty(ex.StackTrace))
  17. {
  18. message += " | Stack Trace: " + ex.StackTrace;
  19. }
  20. return message;
  21. }
  22. }
  23. }