diff --git a/src/main/java/lv/ctco/springboottemplate/exception/GlobalExceptionHandler.java b/src/main/java/lv/ctco/springboottemplate/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..ec9cb49 --- /dev/null +++ b/src/main/java/lv/ctco/springboottemplate/exception/GlobalExceptionHandler.java @@ -0,0 +1,16 @@ +package lv.ctco.springboottemplate.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 GlobalExceptionHandler { + + @ExceptionHandler(Exception.class) + public ResponseEntity handleException(Exception ex) { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body("Oops, something went wrong, try later"); + } +}