HappierCowsControllerAdvice.java

  1. package edu.ucsb.cs156.happiercows.advice;

  2. import org.springframework.http.HttpStatus;
  3. import org.springframework.web.bind.annotation.ExceptionHandler;
  4. import org.springframework.web.bind.annotation.ResponseStatus;
  5. import org.springframework.web.bind.annotation.RestControllerAdvice;

  6. import lombok.extern.slf4j.Slf4j;


  7. /**
  8.  * This class handles exceptions thrown by the controllers.
  9.  */
  10. @Slf4j
  11. @RestControllerAdvice
  12. public class HappierCowsControllerAdvice {

  13.     @ExceptionHandler(IllegalArgumentException.class)
  14.     @ResponseStatus(HttpStatus.BAD_REQUEST)
  15.     public void handleIllegalArgumentException() {
  16.         log.error("IllegalArgumentException thrown");
  17.     }

  18. }