|
|
@@ -0,0 +1,20 @@
|
|
|
+package com.danielbohry.stocks.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.danielbohry.stocks.Error;
|
|
|
+import feign.FeignException;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
+import org.springframework.web.bind.annotation.ControllerAdvice;
|
|
|
+import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
+import org.springframework.web.context.request.WebRequest;
|
|
|
+
|
|
|
+@ControllerAdvice
|
|
|
+public class GlobalExceptionHandler {
|
|
|
+
|
|
|
+ @ExceptionHandler(FeignException.NotFound.class)
|
|
|
+ public ResponseEntity<Error> handleFeignStatusException(FeignException e, WebRequest request) {
|
|
|
+ return ResponseEntity.status(HttpStatus.NOT_FOUND).body(new Error(e.getMessage()));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|