|
|
@@ -2,6 +2,7 @@ package space.anyi.serve.handler;
|
|
|
|
|
|
import jakarta.validation.ConstraintViolationException;
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.security.authentication.BadCredentialsException;
|
|
|
import org.springframework.security.core.AuthenticationException;
|
|
|
import org.springframework.validation.BindException;
|
|
|
import org.springframework.validation.FieldError;
|
|
|
@@ -63,9 +64,14 @@ public class GlobalExceptionHandler {
|
|
|
return Response.error("参数不合法",fieldErrors);
|
|
|
}
|
|
|
|
|
|
+ @ExceptionHandler(BadCredentialsException.class)
|
|
|
+ public Response<String> handleBadCredentials(BadCredentialsException ex) {
|
|
|
+ return Response.error("账号或密码错误");
|
|
|
+ }
|
|
|
+
|
|
|
@ExceptionHandler(AuthenticationException.class)
|
|
|
public Response<String> handleAuthenticationException(AuthenticationException ex) {
|
|
|
- return Response.error(ex.getMessage());
|
|
|
+ return Response.error("账号或密码错误");
|
|
|
}
|
|
|
|
|
|
@ExceptionHandler(Exception.class)
|