Merge der überarbeiteten Compose-Konfiguration ('endless-stream-producer')
[demos/kafka/training] / src / main / java / de / juplo / kafka / DriverController.java
index f8a287d..ce4df68 100644 (file)
@@ -1,7 +1,10 @@
 package de.juplo.kafka;
 
 import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.concurrent.ExecutionException;
@@ -25,4 +28,11 @@ public class DriverController
   {
     producer.stop();
   }
+
+  @ExceptionHandler
+  @ResponseStatus(HttpStatus.BAD_REQUEST)
+  public ErrorResponse illegalStateException(IllegalStateException e)
+  {
+    return new ErrorResponse(e.getMessage(), HttpStatus.BAD_REQUEST.value());
+  }
 }