不积跬步,无以至千里;不积小流,无以成江海

Our practice

不积跬步,无以至千里;不积小流,无以成江海

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
自定义异常是在日常开发中经常使用到的;

异常类代码:
 1    /// <summary>
 2    /// Represents the exception that is thrown when attempting an action that ....
 3    /// </summary>

 4    class SampleException : Exception
 5    {
 6        private string cMessage = string.Empty;
 7        public override string Message
 8        {
 9            get
10            {
11                return cMessage;
12            }

13        }

14        public
SampleException(string pstrMessage)
15        {
16            cMessage = "this is sampe...";
17        }

18    }

调用代码
 try
                        
{
                            ProcessOneRequest(tokens[
0], tokens[1]);
                        }

                        
catch (SampleException ex)
                        
{
                            Utility.WriteLog(“
this is sample!!”);
                        }

posted on 2008-07-10 18:42  英怀  阅读(399)  评论(0编辑  收藏  举报