Skip to content

Commit 65a951e

Browse files
authored
Merge pull request #9 from getyourguide/error-handler
[NO_TICKET] Add error handler
2 parents c1456e1 + cf2c5b6 commit 65a951e

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.getourguide.interview.error;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.ControllerAdvice;
6+
import org.springframework.web.bind.annotation.ExceptionHandler;
7+
8+
@ControllerAdvice
9+
@Slf4j
10+
public class ErrorHandler {
11+
12+
@ExceptionHandler
13+
public ResponseEntity<String> handleException(Exception e) {
14+
log.error("An error occurred", e);
15+
return ResponseEntity.status(500).body("Something went wrong");
16+
}
17+
}
408 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)