1515import software .amazon .awssdk .services .location .model .BatchUpdateDevicePositionResponse ;
1616import software .amazon .awssdk .services .location .model .CalculateRouteRequest ;
1717import software .amazon .awssdk .services .location .model .CalculateRouteResponse ;
18+ import software .amazon .awssdk .services .location .model .ConflictException ;
1819import software .amazon .awssdk .services .location .model .CreateGeofenceCollectionRequest ;
1920import software .amazon .awssdk .services .location .model .CreateGeofenceCollectionResponse ;
2021import software .amazon .awssdk .services .location .model .CreateKeyRequest ;
3839import software .amazon .awssdk .services .location .model .PutGeofenceRequest ;
3940import software .amazon .awssdk .services .location .model .PutGeofenceResponse ;
4041import software .amazon .awssdk .services .location .model .ResourceNotFoundException ;
42+ import software .amazon .awssdk .services .location .model .ServiceQuotaExceededException ;
43+ import software .amazon .awssdk .services .location .model .ThrottlingException ;
44+ import software .amazon .awssdk .services .location .model .ValidationException ;
4145import software .amazon .awssdk .services .location .paginators .ListGeofencesPublisher ;
4246import java .time .Duration ;
4347import java .time .Instant ;
@@ -293,7 +297,7 @@ public CompletableFuture<PutGeofenceResponse> putGeofence(String collectionName,
293297 }
294298
295299 Throwable cause = exception .getCause ();
296- if (cause instanceof LocationException ) {
300+ if (cause instanceof ValidationException ) {
297301 throw new CompletionException ("AWS Location Service error: " + cause .getMessage (), cause );
298302 }
299303 throw new CompletionException ("Error creating geofence: " + exception .getMessage (), exception );
@@ -322,8 +326,8 @@ public CompletableFuture<CreateGeofenceCollectionResponse> createGeofenceCollect
322326 }
323327
324328 Throwable cause = exception .getCause ();
325- if (cause instanceof ResourceNotFoundException ) {
326- throw new CompletionException ("The requested resource was not found while creating the geofence collection. " , cause );
329+ if (cause instanceof ConflictException ) {
330+ throw new CompletionException ("The geofence collection was not created due to a conflict. " , cause );
327331 }
328332 throw new CompletionException ("Failed to create geofence collection: " + exception .getMessage (), exception );
329333 }
@@ -354,31 +358,27 @@ public CompletableFuture<String> createKey(String keyName, String mapArn) {
354358 .whenComplete ((response , exception ) -> {
355359 if (response != null ) {
356360 String keyArn = response .keyArn ();
357- logger .info ("API Key Created : " + keyArn );
361+ logger .info ("The API key was successfully created : " + keyArn );
358362 } else {
359363 if (exception == null ) {
360364 throw new CompletionException ("An unknown error occurred while creating the API key." , null );
361365 }
362366
363367 Throwable cause = exception .getCause ();
364- if (cause instanceof ResourceNotFoundException ) {
365- throw new CompletionException ("The requested resource was not found while creating the API key ." , cause );
368+ if (cause instanceof ThrottlingException ) {
369+ throw new CompletionException ("Request throttling was detected ." , cause );
366370 }
367371 throw new CompletionException ("Failed to create API key: " + exception .getMessage (), exception );
368372 }
369373 }).thenApply (response -> response != null ? response .keyArn () : null ); // Return the key ARN
370374 }
371375
372376 /**
373- * Creates a new map with the specified name and default configuration.
377+ * Creates a new map with the specified name and configuration.
374378 *
375- * @param mapName the name of the map to create
376- * @return a {@link CompletableFuture} that resolves to the Amazon Resource Name (ARN) of the created map, or
377- * {@code null} if the map creation failed
378- * @throws CompletionException if an error occurs while creating the map
379- * - if the requested resource was not found
380- * - if an unknown error occurred
381- * - if the map creation failed for any other reason
379+ * @param mapName the name of the map to be created
380+ * @return a {@link CompletableFuture} that, when completed, will contain the Amazon Resource Name (ARN) of the created map
381+ * @throws CompletionException if an error occurs while creating the map, such as exceeding the service quota
382382 */
383383 public CompletableFuture <String > createMap (String mapName ) {
384384 MapConfiguration configuration = MapConfiguration .builder ()
@@ -401,8 +401,8 @@ public CompletableFuture<String> createMap(String mapName) {
401401 }
402402
403403 Throwable cause = exception .getCause ();
404- if (cause instanceof ResourceNotFoundException ) {
405- throw new CompletionException ("The requested resource was not found while creating the map ." , cause );
404+ if (cause instanceof ServiceQuotaExceededException ) {
405+ throw new CompletionException ("The operation was denied because the request would exceed the maximum quota ." , cause );
406406 }
407407 throw new CompletionException ("Failed to create map: " + exception .getMessage (), exception );
408408 }
0 commit comments