mirror of
https://github.com/ulitsaRaskolnikova/is-coursework.git
synced 2026-09-14 14:05:36 +05:00
Add exceptions
This commit is contained in:
parent
cef6fd99c6
commit
db151b4fd9
@ -47,6 +47,20 @@ public class GlobalExceptionHandler {
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse.error(error));
|
||||
}
|
||||
|
||||
@ExceptionHandler(TOTPRequiredException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleTotpRequired(TOTPRequiredException e) {
|
||||
log.error("TOTP required: {}", e.getMessage());
|
||||
ApiError error = new ApiError("TOTP_REQUIRED", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse.error(error));
|
||||
}
|
||||
|
||||
@ExceptionHandler(InvalidTOTPException.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleInvalidTotp(InvalidTOTPException e) {
|
||||
log.error("Invalid TOTP: {}", e.getMessage());
|
||||
ApiError error = new ApiError("INVALID_TOTP", e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(ApiResponse.error(error));
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseEntity<ApiResponse<Void>> handleGenericException(Exception e) {
|
||||
log.error("Unexpected error: ", e);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package ru.itmo.auth.exception;
|
||||
|
||||
public class InvalidTOTPException extends RuntimeException{
|
||||
public class InvalidTOTPException extends RuntimeException {
|
||||
public InvalidTOTPException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package ru.itmo.auth.exception;
|
||||
|
||||
public class TOTPRequiredException extends RuntimeException{
|
||||
public class TOTPRequiredException extends RuntimeException {
|
||||
public TOTPRequiredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user