全局异常处理

大异常类:
/**
 * 业务异常
 */
public class BaseException extends RuntimeException {

    public BaseException() {
    }

    public BaseException(String msg) {
        super(msg);
    }

}

小分类异常类:

/**
 * 定义员工为空的异常类
 */
public class EmployeeNullException extends BaseException {

        public EmployeeNullException() {
        }
        public EmployeeNullException(String message) {
            super(message);
        }
}

3.信息提示常量类

/**
 * 信息提示常量类
 */
public class MessageConstant {

    public static final String PASSWORD_ERROR = "密码错误";
    public static final String ACCOUNT_NOT_FOUND = "账号不存在";
    public static final String ACCOUNT_LOCKED = "账号被锁定";
    public static final String UNKNOWN_ERROR = "未知错误";
    public static final String USER_NOT_LOGIN = "用户未登录";
    public static final String CATEGORY_BE_RELATED_BY_SETMEAL = "当前分类关联了套餐,不能删除";
    public static final String CATEGORY_BE_RELATED_BY_DISH = "当前分类关联了菜品,不能删除";
    public static final String SHOPPING_CART_IS_NULL = "购物车数据为空,不能下单";
    public static final String ADDRESS_BOOK_IS_NULL = "用户地址为空,不能下单";
    public static final String LOGIN_FAILED = "登录失败";
    public static final String UPLOAD_FAILED = "文件上传失败";
    public static final String SETMEAL_ENABLE_FAILED = "套餐内包含未启售菜品,无法启售";
    public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
    public static final String DISH_ON_SALE = "起售中的菜品不能删除";
    public static final String SETMEAL_ON_SALE = "起售中的套餐不能删除";
    public static final String DISH_BE_RELATED_BY_SETMEAL = "当前菜品关联了套餐,不能删除";
    public static final String ORDER_STATUS_ERROR = "订单状态错误";
    public static final String ORDER_NOT_FOUND = "订单不存在";
    public static final String ACCOUNT_EXISTS ="该账号已经存在";
    public static final Object PARAM_ILLEGAL ="分类参数不合法";
    public static final String DISH_NAME_EXIST = "菜品名称已存在";
    public static final String ARGS_ERROR = "参数错误";
    public static final String INSERT_SUCCESSED = "添加购物车成功";
    public static final String SAVE_SUCCES = "新增成功";
    public static final String DELETE_SUCCES = "删除成功";
    public static final String UPDATE_SUCCES = "修改成功";
    /**
     * 参数不能为空
     *
     */
    private static final String PARAMETER_NULL = "参数不能为空";

    /**
     * 新增员工信息不能为空
     */
    private static final String EMPLOYEE_NULL = "新增员工信息不能为空";

    /**
     * 手机号必须11位
     */
    private static final String PHONE_LENGTH = "手机号必须11位";
    /**
     * 身份证号必须18位
     */
    private static final String IDNUMBER_LENGTH = "身份证号必须18位";
    /**
     * 该账号已经存在
     */
   private static final String ACCOUNT_EXIST = "该账号已经存在";

}

4.

/**
 * 状态常量,启用或者禁用
 */
public class StatusConstant {

    //启用
    public static final Integer ENABLE = 1;
    //禁用
    public static final Integer DISABLE = 0;
}

全局异常处理_第1张图片

你可能感兴趣的:(java,开发语言)