From f6894d3885d12c74170584e88ac987d68fa51935 Mon Sep 17 00:00:00 2001 From: lkw2731938298 <133633447+lkw2731938298@users.noreply.github.com> Date: Wed, 23 Apr 2025 21:34:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=955?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../market/common/exception/BusinessException.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/superMarket-backend/src/main/java/com/shanzhu/market/common/exception/BusinessException.java b/superMarket-backend/src/main/java/com/shanzhu/market/common/exception/BusinessException.java index 31555a4..618b012 100644 --- a/superMarket-backend/src/main/java/com/shanzhu/market/common/exception/BusinessException.java +++ b/superMarket-backend/src/main/java/com/shanzhu/market/common/exception/BusinessException.java @@ -1,13 +1,23 @@ package com.shanzhu.market.common.exception; +// 声明当前类所在的包路径(异常处理模块的基础包) import com.shanzhu.market.common.constants.HttpStatus; +// 导入包含HTTP状态码常量的工具类 public class BusinessException extends SysException { +// 定义业务异常类,继承自系统基础异常类SysException + public BusinessException(String message, Integer code) { + // 全参数构造方法(接收自定义错误消息和数字状态码) + super(message, code); + // 调用父类构造器初始化异常基类属性 } public BusinessException(String msg) { + // 简化构造方法(仅接收错误消息参数) + super(msg, HttpStatus.CODE_BUSINESS_ERROR); + // 调用父类构造器,使用预定义的业务异常状态码常量 } }