65 lines
1.3 KiB
Java
Raw Normal View History

2021-08-16 16:25:25 +08:00
package com.ruoyi.common.exception;
/**
* 业务异常
2021-10-22 10:04:15 +08:00
*
2021-08-16 16:25:25 +08:00
* @author ruoyi
*/
2021-10-22 10:04:15 +08:00
public final class ServiceException extends RuntimeException {
2021-08-16 16:25:25 +08:00
private static final long serialVersionUID = 1L;
/**
* 错误码
*/
private Integer code;
/**
* 错误提示
*/
private String message;
/**
* 错误明细内部调试错误
2021-10-22 10:04:15 +08:00
* <p>
2021-08-16 16:25:25 +08:00
* {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
/**
* 空构造方法避免反序列化问题
*/
2021-10-22 10:04:15 +08:00
public ServiceException() {
2021-08-16 16:25:25 +08:00
}
2021-10-22 10:04:15 +08:00
public ServiceException(String message) {
2021-08-16 16:25:25 +08:00
this.message = message;
}
2021-10-22 10:04:15 +08:00
public ServiceException(String message, Integer code) {
2021-08-16 16:25:25 +08:00
this.message = message;
this.code = code;
}
2021-10-22 10:04:15 +08:00
public String getDetailMessage() {
2021-08-16 16:25:25 +08:00
return detailMessage;
}
2021-10-22 10:04:15 +08:00
@Override
public String getMessage() {
2021-08-16 16:25:25 +08:00
return message;
}
2021-10-22 10:04:15 +08:00
public Integer getCode() {
2021-08-16 16:25:25 +08:00
return code;
}
2021-10-22 10:04:15 +08:00
public ServiceException setMessage(String message) {
2021-08-16 16:25:25 +08:00
this.message = message;
return this;
}
2021-10-22 10:04:15 +08:00
public ServiceException setDetailMessage(String detailMessage) {
2021-08-16 16:25:25 +08:00
this.detailMessage = detailMessage;
return this;
}
}