diff --git a/src/main/java/im/zhaojun/zfile/exception/GlobleExceptionHandler.java b/src/main/java/im/zhaojun/zfile/exception/GlobleExceptionHandler.java index 1c1a951..460c5e1 100644 --- a/src/main/java/im/zhaojun/zfile/exception/GlobleExceptionHandler.java +++ b/src/main/java/im/zhaojun/zfile/exception/GlobleExceptionHandler.java @@ -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); diff --git a/src/main/java/im/zhaojun/zfile/exception/InvalidShortLinkException.java b/src/main/java/im/zhaojun/zfile/exception/InvalidShortLinkException.java new file mode 100644 index 0000000..1569218 --- /dev/null +++ b/src/main/java/im/zhaojun/zfile/exception/InvalidShortLinkException.java @@ -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); + } +} diff --git a/src/main/java/im/zhaojun/zfile/exception/NotAllowedDownloadException.java b/src/main/java/im/zhaojun/zfile/exception/NotAllowedDownloadException.java new file mode 100644 index 0000000..9d9407e --- /dev/null +++ b/src/main/java/im/zhaojun/zfile/exception/NotAllowedDownloadException.java @@ -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); + } +} diff --git a/src/main/java/im/zhaojun/zfile/exception/NotExistFileException.java b/src/main/java/im/zhaojun/zfile/exception/NotExistFileException.java index 41ef396..ed63c11 100644 --- a/src/main/java/im/zhaojun/zfile/exception/NotExistFileException.java +++ b/src/main/java/im/zhaojun/zfile/exception/NotExistFileException.java @@ -1,6 +1,7 @@ package im.zhaojun.zfile.exception; /** + * 不存在的文件异常 * @author zhaojun */ public class NotExistFileException extends RuntimeException { diff --git a/src/main/java/im/zhaojun/zfile/exception/PasswordVerifyException.java b/src/main/java/im/zhaojun/zfile/exception/PasswordVerifyException.java new file mode 100644 index 0000000..27d397c --- /dev/null +++ b/src/main/java/im/zhaojun/zfile/exception/PasswordVerifyException.java @@ -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); + } +} \ No newline at end of file