This commit is contained in:
2026-01-20 16:57:51 +07:00
parent c782c94958
commit 8086bcfe0c
61 changed files with 2894 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
package com.dken.userservice.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.util.Map;
@RestControllerAdvice
public class GlobalExceptionHandler {
@ExceptionHandler(DefaultException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Map<String, String> handleDefaultException(DefaultException ex) {
return Map.of("message", ex.getMessage());
}
@ExceptionHandler(InvalidUserIdException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public Map<String, String> handleInvalidId(InvalidUserIdException ex) {
return Map.of("message", ex.getMessage());
}
@ExceptionHandler(UserNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public Map<String, String> handleNotFound(UserNotFoundException ex) {
return Map.of("message", ex.getMessage());
}
}