60 lines
1012 B
Java
60 lines
1012 B
Java
package com.test.musichouduan.exception;
|
|
|
|
/**
|
|
* 业务异常
|
|
*/
|
|
public class BusinessException extends RuntimeException {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
/**
|
|
* 错误码
|
|
*/
|
|
private Integer code;
|
|
|
|
/**
|
|
* 错误消息
|
|
*/
|
|
private String message;
|
|
|
|
/**
|
|
* 构造方法
|
|
*
|
|
* @param message 错误消息
|
|
*/
|
|
public BusinessException(String message) {
|
|
this.code = 500;
|
|
this.message = message;
|
|
}
|
|
|
|
/**
|
|
* 构造方法
|
|
*
|
|
* @param code 错误码
|
|
* @param message 错误消息
|
|
*/
|
|
public BusinessException(Integer code, String message) {
|
|
this.code = code;
|
|
this.message = message;
|
|
}
|
|
|
|
/**
|
|
* 获取错误码
|
|
*
|
|
* @return 错误码
|
|
*/
|
|
public Integer getCode() {
|
|
return code;
|
|
}
|
|
|
|
/**
|
|
* 获取错误消息
|
|
*
|
|
* @return 错误消息
|
|
*/
|
|
@Override
|
|
public String getMessage() {
|
|
return message;
|
|
}
|
|
}
|