zoukankan      html  css  js  c++  java
  • 今日总结

    今天的内容

    自定义异常处理

    package com.dyhospital.cloudhis.common.web.exception.reg.exception;
    
    import org.apache.commons.lang.StringUtils
    public class BizException extends RuntimeException {
     
        private static final long serialVersionUID = -7864604160297181941L;
     
        /** 错误码 */
        protected final ErrorCode errorCode;
     
        /**
         * 这个是和谐一些不必要的地方,冗余的字段
         * 尽量不要用
         */
        private String code;
     
        /**
         * 无参默认构造UNSPECIFIED
         */
        public BizException() {
            super(BizErrorCodeEnum.UNSPECIFIED.getDescription());
            this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
        }
     
        /**
         * 指定错误码构造通用异常
         * @param errorCode 错误码
         */
        public BizException(final ErrorCode errorCode) {
            super(errorCode.getDescription());
            this.errorCode = errorCode;
        }
     
        /**
         * 指定详细描述构造通用异常
         * @param detailedMessage 详细描述
         */
        public BizException(final String detailedMessage) {
            super(detailedMessage);
            this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
        }
     
        /**
         * 指定导火索构造通用异常
         * @param t 导火索
         */
        public BizException(final Throwable t) {
            super(t);
            this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
        }
     
        /**
         * 构造通用异常
         * @param errorCode 错误码
         * @param detailedMessage 详细描述
         */
        public BizException(final ErrorCode errorCode, final String detailedMessage) {
            super(detailedMessage);
            this.errorCode = errorCode;
        }
     
        /**
         * 构造通用异常
         * @param errorCode 错误码
         * @param t 导火索
         */
        public BizException(final ErrorCode errorCode, final Throwable t) {
            super(errorCode.getDescription(), t);
            this.errorCode = errorCode;
        }
     
        /**
         * 构造通用异常
         * @param detailedMessage 详细描述
         * @param t 导火索
         */
        public BizException(final String detailedMessage, final Throwable t) {
            super(detailedMessage, t);
            this.errorCode = BizErrorCodeEnum.UNSPECIFIED;
        }
     
        /**
         * 构造通用异常
         * @param errorCode 错误码
         * @param detailedMessage 详细描述
         * @param t 导火索
         */
        public BizException(final ErrorCode errorCode, final String detailedMessage,
                            final Throwable t) {
            super(detailedMessage, t);
            this.errorCode = errorCode;
        }
     
        /**
         * Getter method for property <tt>errorCode</tt>.
         *
         * @return property value of errorCode
         */
        public ErrorCode getErrorCode() {
            return errorCode;
        }
     
     
    }

    问题:无

    明天的打算:继续学习Java

  • 相关阅读:
    andorid UI事件 监听器
    12小时进制的时间输出的编辑代码
    Java运算符
    运算符的优先级
    UTF-8
    对ASCII的了解
    数组
    Java语法基础
    Java的跨平台
    指针的了解
  • 原文地址:https://www.cnblogs.com/MXming/p/14162245.html
Copyright © 2011-2022 走看看