Skip to content

Commit 3bf76d4

Browse files
authored
Merge pull request #45 from target/PNA-2105
Handling Error Stream Exceptions
2 parents 8551ba0 + cb86c62 commit 3bf76d4

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/main/java/com/target/devicemanager/common/DeviceAvailabilityController.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,17 @@ public DeviceAvailabilityResponse getDeviceAvailability() {
4444
@GetMapping("/v1/deviceerror")
4545
public SseEmitter getDeviceError() throws IOException {
4646
LOGGER.info("GET : /v1/deviceerror");
47-
SseEmitter sseEmitter = new SseEmitter(Long.MAX_VALUE);
48-
deviceAvailabilityService.subscribeToDeviceError(sseEmitter);
49-
return sseEmitter;
47+
try {
48+
SseEmitter sseEmitter = new SseEmitter(Long.MAX_VALUE);
49+
deviceAvailabilityService.subscribeToDeviceError(sseEmitter);
50+
return sseEmitter;
51+
} catch (IOException ioException) {
52+
LOGGER.info("IOException in DeviceError: " + ioException.getMessage());
53+
throw ioException;
54+
} catch (Exception exception) {
55+
LOGGER.info("Exception in DeviceError: " + exception.getMessage());
56+
throw exception;
57+
}
5058
}
5159

5260
@Operation(description = "Health status of all devices")

0 commit comments

Comments
 (0)