mirror of
https://github.com/zfile-dev/zfile.git
synced 2025-04-19 05:34:52 +00:00
✨ 完善异常处理机制,新增异常类
This commit is contained in:
@@ -4,7 +4,6 @@ import im.zhaojun.zfile.model.support.ResultBean;
|
||||
import org.apache.catalina.connector.ClientAbortException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.HttpMediaTypeNotAcceptableException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
@@ -42,6 +41,16 @@ public class GlobleExceptionHandler {
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件预览异常
|
||||
*/
|
||||
@ExceptionHandler({PasswordVerifyException.class})
|
||||
@ResponseBody
|
||||
@ResponseStatus
|
||||
public ResultBean passwordVerifyException(PasswordVerifyException ex) {
|
||||
return ResultBean.error(ex.getMessage());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 文件预览异常
|
||||
@@ -67,7 +76,7 @@ public class GlobleExceptionHandler {
|
||||
|
||||
@ExceptionHandler
|
||||
@ResponseBody
|
||||
@ResponseStatus(code= HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
@ResponseStatus
|
||||
public ResultBean searchDisableExceptionHandler(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package im.zhaojun.zfile.exception;
|
||||
|
||||
/**
|
||||
* 无效的直链异常
|
||||
* @author zhaojun
|
||||
*/
|
||||
public class InvalidShortLinkException extends RuntimeException {
|
||||
public InvalidShortLinkException() {
|
||||
}
|
||||
|
||||
public InvalidShortLinkException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidShortLinkException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvalidShortLinkException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InvalidShortLinkException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package im.zhaojun.zfile.exception;
|
||||
|
||||
/**
|
||||
* 文件不允许下载异常
|
||||
* @author zhaojun
|
||||
*/
|
||||
public class NotAllowedDownloadException extends RuntimeException {
|
||||
public NotAllowedDownloadException() {
|
||||
}
|
||||
|
||||
public NotAllowedDownloadException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NotAllowedDownloadException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public NotAllowedDownloadException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public NotAllowedDownloadException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package im.zhaojun.zfile.exception;
|
||||
|
||||
/**
|
||||
* 不存在的文件异常
|
||||
* @author zhaojun
|
||||
*/
|
||||
public class NotExistFileException extends RuntimeException {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package im.zhaojun.zfile.exception;
|
||||
|
||||
/**
|
||||
* 密码校验失败异常
|
||||
* @author zhaojun
|
||||
*/
|
||||
public class PasswordVerifyException extends RuntimeException {
|
||||
|
||||
public PasswordVerifyException() {
|
||||
}
|
||||
|
||||
public PasswordVerifyException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public PasswordVerifyException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public PasswordVerifyException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public PasswordVerifyException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user