PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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