Skip to content

Commit cd4265e

Browse files
committed
rolled in review comments
1 parent 7ffc230 commit cd4265e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

javav2/example_code/iotfleetwise/src/main/java/com/example/fleetwise/scenario/FleetwiseActions.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,9 @@ public CompletableFuture<Void> deleteDecoderManifestAsync(String name) {
262262
if (exception != null) {
263263
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
264264
if (cause instanceof ResourceNotFoundException) {
265-
throw new RuntimeException("Decoder manifest not found: " + name, cause);
265+
throw (ResourceNotFoundException) cause;
266266
}
267-
throw new RuntimeException("Failed to delete decoder manifest: " + name, cause);
267+
throw new RuntimeException("Failed to delete the decoder manifest: " + cause);
268268
}
269269
return null;
270270
});
@@ -289,9 +289,9 @@ public CompletableFuture<Void> deleteVehicleAsync(String vecName) {
289289
if (exception != null) {
290290
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
291291
if (cause instanceof ResourceNotFoundException) {
292-
throw new RuntimeException("Failed to locate the vehicle: " + vecName, cause);
292+
throw (ResourceNotFoundException) cause;
293293
}
294-
throw new RuntimeException("Failed to delete vehicle: " + vecName, cause);
294+
throw new RuntimeException("Failed to delete the vehicle: " + cause);
295295
}
296296
return null;
297297
});
@@ -617,9 +617,9 @@ public CompletableFuture<Void> deleteModelManifestAsync(String name) {
617617
if (exception != null) {
618618
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
619619
if (cause instanceof ResourceNotFoundException) {
620-
throw new RuntimeException("Failed to locate the model manifest: " + name, cause);
620+
throw (ResourceNotFoundException) cause;
621621
}
622-
throw new RuntimeException("Failed to delete model manifest: " + name, cause);
622+
throw new RuntimeException("Failed to delete the model manifest: " + cause);
623623
}
624624
logger.info("{} was successfully deleted", name);
625625
return null;
@@ -645,9 +645,9 @@ public CompletableFuture<Void> deleteSignalCatalogAsync(String name) {
645645
if (exception != null) {
646646
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
647647
if (cause instanceof ResourceNotFoundException) {
648-
throw new RuntimeException("Failed to locate the signal catalog: " + name, cause);
648+
throw (ResourceNotFoundException) cause;
649649
}
650-
throw new RuntimeException("Failed to delete signal catalog: " + name, cause);
650+
throw new RuntimeException("Failed to delete the signal catalog: " + cause);
651651
}
652652
logger.info("{} was successfully deleted", name);
653653
return null;
@@ -749,9 +749,9 @@ public CompletableFuture<Void> deleteFleetAsync(String fleetId) {
749749
if (exception != null) {
750750
Throwable cause = exception.getCause() != null ? exception.getCause() : exception;
751751
if (cause instanceof ResourceNotFoundException) {
752-
throw new RuntimeException("Failed to locate the fleet: " + fleetId, cause);
752+
throw (ResourceNotFoundException) cause;
753753
}
754-
throw new RuntimeException("Failed to delete fleet: " + fleetId, cause);
754+
throw new RuntimeException("Failed to delete the fleet: " + cause);
755755
}
756756
logger.info("{} was successfully deleted", fleetId);
757757
return null;

javav2/example_code/iotfleetwise/src/main/java/com/example/fleetwise/scenario/FleetwiseScenario.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,14 @@ Before calling createVehicle(), you must create an AWS IoT Thing
297297
} catch (CompletionException ce) {
298298
Throwable cause = ce.getCause();
299299
if (cause instanceof ResourceNotFoundException) {
300+
// Handle the case where the resource is not found.
300301
logger.error("The resource was not found: {}", cause.getMessage());
302+
} else if (cause instanceof RuntimeException) {
303+
// Handle other runtime exceptions.
304+
logger.error("An unexpected error occurred: {}", cause.getMessage());
301305
} else {
302-
logger.error("An unexpected error occurred.", cause);
306+
// Catch any other unexpected exceptions.
307+
logger.error("An unknown error occurred.", cause);
303308
}
304309
return;
305310
}

0 commit comments

Comments
 (0)