The next generation of the Teknik Services. Written in ASP.NET. Fork for blog tags.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

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. }