/projects/PigeonCms.Core/BLL/CustomException.cs

http://pigeoncms.googlecode.com/ · C# · 79 lines · 62 code · 12 blank · 5 comment · 0 complexity · aa884df69922befc121c00de4a941f64 MD5 · raw file

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.HtmlControls;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. namespace PigeonCms
  11. {
  12. /// <summary>
  13. /// Severity level of Exception
  14. /// </summary>
  15. public enum CustomExceptionSeverity
  16. {
  17. Info,
  18. Warning,
  19. Critical,
  20. Fatal
  21. }
  22. public enum CustomExceptionLogLevel
  23. {
  24. Debug,
  25. Log
  26. }
  27. public class CustomException: Exception
  28. {
  29. private CustomExceptionSeverity severity = CustomExceptionSeverity.Warning;
  30. private CustomExceptionLogLevel logLevel = CustomExceptionLogLevel.Debug;
  31. private string customMessage = "";
  32. public CustomExceptionSeverity Severity
  33. {
  34. get { return severity; }
  35. }
  36. public CustomExceptionLogLevel LogLevel
  37. {
  38. get { return logLevel; }
  39. }
  40. public string CustomMessage
  41. {
  42. get { return customMessage; }
  43. }
  44. public CustomException()
  45. {
  46. }
  47. public CustomException(string customMessage)
  48. {
  49. this.customMessage = customMessage;
  50. }
  51. public CustomException(string customMessage, CustomExceptionSeverity severity, CustomExceptionLogLevel logLevel)
  52. {
  53. this.customMessage = customMessage;
  54. this.severity = severity;
  55. this.logLevel = logLevel;
  56. PigeonCms.Tracer.Log("CustomException: "+ this.ToString(), TracerItemType.Error, this);
  57. //PigeonCms.Debug.Write("CustomException", this);
  58. }
  59. public override string ToString()
  60. {
  61. //return base.ToString();
  62. return "Message:" + this.CustomMessage + "; "+
  63. "Severity:" + this.Severity.ToString()+ "; " +
  64. "LogLevel:" + this.LogLevel.ToString() + "; ";
  65. }
  66. }
  67. }