package com.mongo.demo.exception; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; @RestControllerAdvice public class EmployeeExceptionController { @ExceptionHandler(value = EmployeeNotFoundException.class) public ResponseEntity handleException(EmployeeNotFoundException exception){ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(exception.getMessage()); } }