zoukankan      html  css  js  c++  java
  • 自定义Exception——实战篇

        public class EntityConfigurationException : Exception
        {
            public EntityConfigurationException(string message) : base(message)
            {
            }
        }
    

      

        /// <summary>
        /// *****异常
        /// </summary>
        public class  *****Exception : Exception
        {
            /// <summary>
            /// 操作结果
            /// </summary>
            public OPResult Result { get; set; }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="opr">操作结果</param>
            /// <param name="message">消息内容</param>
            public  *****Exception(OPResult opr, String message)
                : base(message)
            {
    
                Result = opr;
            }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="opr">返回代码</param>
            /// <param name="message">错误消息</param>
            /// <param name="e">原始异常</param>
            public  *****Exception(OPResult opr, String message, Exception e)
                : base(message, e)
            {
                Result = opr;
            }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="message">消息内容</param>
            /// <param name="e">异常栈</param>
            public  *****Exception(String message, Exception e)
                : base(message, e)
            {
                Result = OPResult.ServerError;
            }
    
            /// <summary>
            /// 构造函数
            /// </summary>
            /// <param name="e">异常堆栈</param>
            public  *****Exception(Exception e)
                : base("Server Operation Failed", e)
            {
                Result = OPResult.ServerError;
            }
        }
    
        /// <summary>
        /// 操作结果
        /// </summary>
        public class  *****OPResult
        {
            /// <summary>
            /// 操作是否成功
            /// </summary>
            public Boolean OPSucess { get; set; }
            /// <summary>
            /// 结果代码
            /// </summary>
            public OPResult OPCode { get; set; }
            /// <summary>
            /// 操作结果,类型可变,由Type进行判断
            /// </summary>
            public Object ResultContent { get; set; }
            /// <summary>
            /// 返回类型名称
            /// </summary>
            public String Type { get; set; }
    
            /// <summary>
            /// 返回是否为数组
            /// </summary>
            public Boolean IsArray { get; set; }
        }
    

      

        /// <summary>
        /// 操作结果
        /// </summary>
        public enum OPResult : int
        {
            /// <summary>
            /// 成功
            /// </summary>
            Success = 0,
            /// <summary>
            /// 无效参数
            /// </summary>
            InvalidParameters = 1,
            /// <summary>
            /// 无效用户
            /// </summary>
            InvalidUser = 2,
            /// <summary>
            /// 无效Token
            /// </summary>
            InvalidToken = 3,
    
            /// <summary>
            /// 参数缺失
            /// </summary>
            MissingParameters=4,
            /// <summary>
            /// 服务器端错误
            /// </summary>
            ServerError = 0xFF
        }
    

      

  • 相关阅读:
    Fedora 19+ 启动顺序调整
    朗科U903 低级格式化后,量产错误:read onlypage (控制器芯片群联2251-03)的解决方案
    python中快速删除实例对象中的所有属性
    python中如何用sys.excepthook来对全局异常进行捕获、显示及输出到error日志中
    通过ctypes获得python windows process的内存使用情况
    Python的XMLRPC机制:实现跨进程间、client/server端通信
    PIL Image 转成 wx.Image、wx.Bitmap
    wxpython线程安全的方法
    11
    列表去重的几种方法
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/8601725.html
Copyright © 2011-2022 走看看