Skip to content

Commit 9f6d0dd

Browse files
committed
feat: add GlobalExceptionHandler.java
1 parent 72bb153 commit 9f6d0dd

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.example.SorokinSpringBoot.exceptions;
2+
3+
import org.springframework.http.ResponseEntity;
4+
import org.springframework.web.bind.annotation.ControllerAdvice;
5+
import org.springframework.web.bind.annotation.ExceptionHandler;
6+
7+
import java.util.logging.Logger;
8+
9+
@ControllerAdvice
10+
public class GlobalExceptionHandler {
11+
12+
private static final Logger logger = Logger.getLogger(GlobalExceptionHandler.class.getName());
13+
14+
@ExceptionHandler(Exception.class)
15+
public ResponseEntity<Void> handleGenericException(Exception exception) {
16+
logger.warning("Handle exception" + exception);
17+
return ResponseEntity.status(500).build();
18+
}
19+
20+
}

0 commit comments

Comments
 (0)