package de.platesoft.auth.config; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; /** * Global exception handler for plate-auth controllers. */ @RestControllerAdvice(basePackages = "de.platesoft.auth.controller") public class PlateAuthExceptionHandler { @ExceptionHandler(SecurityException.class) public ResponseEntity handleSecurityException(SecurityException e) { return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(e.getMessage()); } @ExceptionHandler(IllegalArgumentException.class) public ResponseEntity handleIllegalArgument(IllegalArgumentException e) { return ResponseEntity.badRequest().body(e.getMessage()); } @ExceptionHandler(Exception.class) public ResponseEntity handleGenericException(Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body("Internal error: " + e.getClass().getSimpleName() + ": " + e.getMessage()); } }