123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package cn.iocoder.dashboard.common.exception;
- import cn.iocoder.dashboard.common.exception.enums.ServiceErrorCodeRange;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- /**
- * 业务逻辑异常 Exception
- */
- @Data
- @EqualsAndHashCode(callSuper = true)
- public final class ServiceException extends RuntimeException {
- /**
- * 业务错误码
- *
- * @see ServiceErrorCodeRange
- */
- private Integer code;
- /**
- * 错误提示
- */
- private String message;
- /**
- * 空构造方法,避免反序列化问题
- */
- public ServiceException() {
- }
- public ServiceException(ErrorCode errorCode) {
- this.code = errorCode.getCode();
- this.message = errorCode.getMsg();
- }
- public ServiceException(Integer code, String message) {
- this.code = code;
- this.message = message;
- }
- public Integer getCode() {
- return code;
- }
- public ServiceException setCode(Integer code) {
- this.code = code;
- return this;
- }
- @Override
- public String getMessage() {
- return message;
- }
- public ServiceException setMessage(String message) {
- this.message = message;
- return this;
- }
- }
|