mirror of
https://github.com/201206030/novel.git
synced 2025-04-26 15:20:50 +00:00
feat: 处理404异常
This commit is contained in:
parent
cd3a7206a9
commit
a23f4b202e
@ -3,9 +3,12 @@ package io.github.xxyopen.novel.core.common.exception;
|
||||
import io.github.xxyopen.novel.core.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
import org.springframework.web.servlet.resource.NoResourceFoundException;
|
||||
|
||||
/**
|
||||
* 通用的异常处理器
|
||||
@ -17,6 +20,15 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
@RestControllerAdvice
|
||||
public class CommonExceptionHandler {
|
||||
|
||||
/**
|
||||
* 处理404异常
|
||||
*/
|
||||
@ExceptionHandler(NoResourceFoundException.class)
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND)
|
||||
public String handlerNotFound() {
|
||||
return "404";
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据校验异常
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user