From 60517dab7bb094613f103a28265962a6ad2fbe20 Mon Sep 17 00:00:00 2001 From: vcolin7 Date: Thu, 13 May 2021 17:50:53 -0500 Subject: [PATCH] Tables exception and error classes changes. (#21339) * Renamed TableServiceErrorException to TableServiceException. * Made TableErrorCode final and added a lot more error codes to it. * Removed languageCode from TableServiceError. * Corrected error values in TableErrorCode. * Removed unused error codes from TableErrorCode. * Imported TableServiceErrorException in TableUtils instead of using it's fully qualified name. * Added a link for getting error codes details to TableErrorCode's JavaDoc. * Removed localization from link in TableErrorCode. --- .../azure/data/tables/TableAsyncBatch.java | 8 +- .../azure/data/tables/TableAsyncClient.java | 88 +++---- .../com/azure/data/tables/TableBatch.java | 8 +- .../com/azure/data/tables/TableClient.java | 70 ++--- .../data/tables/TableServiceAsyncClient.java | 26 +- .../azure/data/tables/TableServiceClient.java | 18 +- .../tables/implementation/TableUtils.java | 34 +-- .../data/tables/models/TableErrorCode.java | 242 +++++++++++++++++- .../data/tables/models/TableServiceError.java | 22 +- ...eption.java => TableServiceException.java} | 10 +- .../tables/models/TableStorageException.java | 55 ---- .../azure/data/tables}/ReadmeSamples.java | 10 +- .../TableServiceAsyncClientCodeSnippets.java | 0 .../TableServiceClientCodeSnippets.java | 36 ++- .../tables/TableServiceAsyncClientTest.java | 6 +- .../data/tables/TableServiceClientTest.java | 4 +- .../data/tables/TablesAsyncClientTest.java | 4 +- 17 files changed, 393 insertions(+), 248 deletions(-) rename sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/{TableServiceErrorException.java => TableServiceException.java} (68%) delete mode 100644 sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableStorageException.java rename sdk/tables/azure-data-tables/src/samples/java/{ => com/azure/data/tables}/ReadmeSamples.java (94%) rename sdk/tables/azure-data-tables/src/samples/java/{ => com/azure/data/tables}/TableServiceAsyncClientCodeSnippets.java (100%) rename sdk/tables/azure-data-tables/src/samples/java/{ => com/azure/data/tables}/TableServiceClientCodeSnippets.java (84%) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncBatch.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncBatch.java index 26e8e9a3a7f4c..52adaad37d158 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncBatch.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncBatch.java @@ -21,7 +21,7 @@ import com.azure.data.tables.implementation.models.BatchSubRequest; import com.azure.data.tables.implementation.models.TableServiceError; import com.azure.data.tables.models.TableEntity; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -253,7 +253,7 @@ public synchronized List getOperations() { * @return A reactive result containing a list of sub-responses for each operation in the batch. * * @throws IllegalStateException If no operations have been added to the batch. - * @throws TableServiceErrorException if any operation within the batch fails. See the documentation for the client + * @throws TableServiceException if any operation within the batch fails. See the documentation for the client * methods in {@link TableAsyncClient} to understand the conditions that may cause a given operation to fail. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -269,7 +269,7 @@ public synchronized Mono> submitTransaction() { * contain a list of sub-responses for each operation in the batch. * * @throws IllegalStateException If no operations have been added to the batch. - * @throws TableServiceErrorException if any operation within the batch fails. See the documentation for the client + * @throws TableServiceException if any operation within the batch fails. See the documentation for the client * methods in {@link TableAsyncClient} to understand the conditions that may cause a given operation to fail. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -355,7 +355,7 @@ private Mono>> parseResponse(BatchRequestB message += " " + errorMessage; } - return monoError(logger, new TableServiceErrorException(message, null, toTableServiceError(error))); + return monoError(logger, new TableServiceException(message, null, toTableServiceError(error))); } else { return Mono.just(new SimpleResponse<>(response, Arrays.asList(response.getValue()))); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java index 6070bf450c978..72a3c8282188a 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableAsyncClient.java @@ -28,7 +28,7 @@ import com.azure.data.tables.implementation.models.TableProperties; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableEntity; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; import reactor.core.publisher.Mono; @@ -50,8 +50,8 @@ * table itself, as well as methods to create, upsert, update, delete, list, and get entities within the table. These * methods invoke REST API operations to make the requests and obtain the results that are returned. * - * Instances of this client are obtained by calling the {@link TableClientBuilder#buildAsyncClient()} method on a {@link - * TableClientBuilder} object. + * Instances of this client are obtained by calling the {@link TableClientBuilder#buildAsyncClient()} method on a + * {@link TableClientBuilder} object. */ @ServiceClient(builder = TableClientBuilder.class, isAsync = true) public final class TableAsyncClient { @@ -179,7 +179,7 @@ AzureTableImpl getImplementation() { * * @return An empty reactive result. * - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono create() { @@ -191,7 +191,7 @@ public Mono create() { * * @return A reactive result containing the HTTP response. * - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createWithResponse() { @@ -205,7 +205,7 @@ Mono> createWithResponse(Context context) { try { return implementation.getTables().createWithResponseAsync(properties, null, ResponseFormat.RETURN_NO_CONTENT, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, null)); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -219,7 +219,7 @@ Mono> createWithResponse(Context context) { * * @return An empty reactive result. * - * @throws TableServiceErrorException If an entity with the same partition key and row key already exists within the + * @throws TableServiceException If an entity with the same partition key and row key already exists within the * table. * @throws IllegalArgumentException If the provided entity is invalid. */ @@ -235,7 +235,7 @@ public Mono createEntity(TableEntity entity) { * * @return A reactive result containing the HTTP response. * - * @throws TableServiceErrorException If an entity with the same partition key and row key already exists within the + * @throws TableServiceException If an entity with the same partition key and row key already exists within the * table. * @throws IllegalArgumentException If the provided entity is invalid. */ @@ -257,7 +257,7 @@ Mono> createEntityWithResponse(TableEntity entity, Duration timeo try { return implementation.getTables().insertEntityWithResponseAsync(tableName, timeoutInt, null, ResponseFormat.RETURN_NO_CONTENT, entity.getProperties(), null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); } catch (RuntimeException ex) { @@ -276,7 +276,7 @@ Mono> createEntityWithResponse(TableEntity entity, Duration timeo * @return An empty reactive result. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono upsertEntity(TableEntity entity) { @@ -300,7 +300,7 @@ public Mono upsertEntity(TableEntity entity) { * @return An empty reactive result. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono upsertEntity(TableEntity entity, UpdateMode updateMode) { @@ -324,7 +324,7 @@ public Mono upsertEntity(TableEntity entity, UpdateMode updateMode) { * @return A reactive result containing the HTTP response. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> upsertEntityWithResponse(TableEntity entity, UpdateMode updateMode) { @@ -346,14 +346,14 @@ Mono> upsertEntityWithResponse(TableEntity entity, UpdateMode upd if (updateMode == UpdateMode.REPLACE) { return implementation.getTables().updateEntityWithResponseAsync(tableName, entity.getPartitionKey(), entity.getRowKey(), timeoutInt, null, null, entity.getProperties(), null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); } else { return implementation.getTables().mergeEntityWithResponseAsync(tableName, entity.getPartitionKey(), entity.getRowKey(), timeoutInt, null, null, entity.getProperties(), null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); @@ -371,7 +371,7 @@ Mono> upsertEntityWithResponse(TableEntity entity, UpdateMode upd * @return An empty reactive result. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table. + * @throws TableServiceException If no entity with the same partition key and row key exists within the table. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono updateEntity(TableEntity entity) { @@ -391,7 +391,7 @@ public Mono updateEntity(TableEntity entity) { * @return An empty reactive result. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table. + * @throws TableServiceException If no entity with the same partition key and row key exists within the table. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono updateEntity(TableEntity entity, UpdateMode updateMode) { @@ -413,7 +413,7 @@ public Mono updateEntity(TableEntity entity, UpdateMode updateMode) { * @return An empty reactive result. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table, + * @throws TableServiceException If no entity with the same partition key and row key exists within the table, * or if {@code ifUnchanged} is {@code true} and the existing entity's eTag does not match that of the provided * entity. */ @@ -438,7 +438,7 @@ public Mono updateEntity(TableEntity entity, UpdateMode updateMode, boolea * @return A reactive result containing the HTTP response. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table, + * @throws TableServiceException If no entity with the same partition key and row key exists within the table, * or if {@code ifUnchanged} is {@code true} and the existing entity's eTag does not match that of the provided * entity. */ @@ -464,14 +464,14 @@ Mono> updateEntityWithResponse(TableEntity entity, UpdateMode upd if (updateMode == UpdateMode.REPLACE) { return implementation.getTables().updateEntityWithResponseAsync(tableName, entity.getPartitionKey(), entity.getRowKey(), timeoutInt, null, eTag, entity.getProperties(), null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); } else { return implementation.getTables().mergeEntityWithResponseAsync(tableName, entity.getPartitionKey(), entity.getRowKey(), timeoutInt, null, eTag, entity.getProperties(), null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); @@ -486,7 +486,7 @@ Mono> updateEntityWithResponse(TableEntity entity, UpdateMode upd * * @return An empty reactive result. * - * @throws TableServiceErrorException If no table with this name exists within the service. + * @throws TableServiceException If no table with this name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono delete() { @@ -498,11 +498,11 @@ public Mono delete() { * * @return A reactive result containing the response. * - * @throws TableServiceErrorException If no table with this name exists within the service. + * @throws TableServiceException If no table with this name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteWithResponse() { - return withContext(context -> deleteWithResponse(context)); + return withContext(this::deleteWithResponse); } Mono> deleteWithResponse(Context context) { @@ -510,7 +510,7 @@ Mono> deleteWithResponse(Context context) { try { return implementation.getTables().deleteWithResponseAsync(tableName, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, null)); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -526,7 +526,7 @@ Mono> deleteWithResponse(Context context) { * @return An empty reactive result. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -545,7 +545,7 @@ public Mono deleteEntity(String partitionKey, String rowKey) { * @return An empty reactive result. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table, or if {@code eTag} is not {@code null} and the existing entity's eTag does not match that of the provided * entity. */ @@ -565,7 +565,7 @@ public Mono deleteEntity(String partitionKey, String rowKey, String eTag) * @return A reactive result containing the response. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table, or if {@code eTag} is not {@code null} and the existing entity's eTag does not match that of the provided * entity. */ @@ -587,7 +587,7 @@ Mono> deleteEntityWithResponse(String partitionKey, String rowKey try { return implementation.getTables().deleteEntityWithResponseAsync(tableName, partitionKey, rowKey, matchParam, timeoutInt, null, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); } catch (RuntimeException ex) { @@ -600,7 +600,7 @@ Mono> deleteEntityWithResponse(String partitionKey, String rowKey * * @return A paged reactive result containing all entities within the table. * - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listEntities() { @@ -619,7 +619,7 @@ public PagedFlux listEntities() { * @return A paged reactive result containing matching entities within the table. * * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listEntities(ListEntitiesOptions options) { @@ -637,7 +637,7 @@ public PagedFlux listEntities(ListEntitiesOptions options) { * @return A paged reactive result containing all entities within the table. * * @throws IllegalArgumentException If an instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listEntities(Class resultType) { @@ -659,7 +659,7 @@ public PagedFlux listEntities(Class resultType) { * * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed, or if * an instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listEntities(ListEntitiesOptions options, Class resultType) { @@ -707,7 +707,7 @@ private Mono> listEntities(String nextP try { return implementation.getTables().queryEntitiesWithResponseAsync(tableName, null, null, nextPartitionKey, nextRowKey, queryOptions, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .flatMap(response -> { final TableEntityQueryResponse tablesQueryEntityResponse = response.getValue(); @@ -791,7 +791,7 @@ public void close() { * @return A reactive result containing the entity. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -810,7 +810,7 @@ public Mono getEntity(String partitionKey, String rowKey) { * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if the * {@code select} OData query option is malformed. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -830,7 +830,7 @@ public Mono getEntity(String partitionKey, String rowKey, String se * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if an * instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -852,7 +852,7 @@ public Mono getEntity(String partitionKey, String row * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, if the * {@code select} OData query option is malformed, or if an instance of the provided {@code resultType} can't be * created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -872,7 +872,7 @@ public Mono getEntity(String partitionKey, String row * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if the * {@code select} OData query option is malformed. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -895,7 +895,7 @@ public Mono> getEntityWithResponse(String partitionKey, St * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, if the * {@code select} OData query option is malformed, or if an instance of the provided {@code resultType} can't be * created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -920,9 +920,9 @@ Mono> getEntityWithResponse(String partition } try { - return implementation.getTables().queryEntityWithPartitionAndRowKeyWithResponseAsync(tableName, partitionKey, - rowKey, timeoutInt, null, queryOptions, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + return implementation.getTables().queryEntityWithPartitionAndRowKeyWithResponseAsync(tableName, + partitionKey, rowKey, timeoutInt, null, queryOptions, context) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .handle((response, sink) -> { final Map matchingEntity = response.getValue(); @@ -937,8 +937,8 @@ Mono> getEntityWithResponse(String partition // Deserialize the first entity. final TableEntity entity = ModelHelper.createEntity(matchingEntity); - sink.next(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), - EntityHelper.convertToSubclass(entity, resultType, logger))); + sink.next(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), + response.getHeaders(), EntityHelper.convertToSubclass(entity, resultType, logger))); }); } catch (RuntimeException ex) { return monoError(logger, ex); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableBatch.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableBatch.java index 05840f1c1c203..193ca568ec163 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableBatch.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableBatch.java @@ -10,7 +10,7 @@ import com.azure.data.tables.implementation.models.BatchOperation; import com.azure.data.tables.models.BatchOperationResponse; import com.azure.data.tables.models.TableEntity; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; import java.time.Duration; @@ -224,7 +224,7 @@ public List getOperations() { * @return A list of sub-responses for each operation in the batch. * * @throws IllegalStateException If no operations have been added to the batch. - * @throws TableServiceErrorException if any operation within the batch fails. See the documentation for the client + * @throws TableServiceException if any operation within the batch fails. See the documentation for the client * methods in {@link TableClient} to understand the conditions that may cause a given operation to fail. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -241,7 +241,7 @@ public List submitTransaction() { * @return A list of sub-responses for each operation in the batch. * * @throws IllegalStateException If no operations have been added to the batch. - * @throws TableServiceErrorException if any operation within the batch fails. See the documentation for the client + * @throws TableServiceException if any operation within the batch fails. See the documentation for the client * methods in {@link TableClient} to understand the conditions that may cause a given operation to fail. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -260,7 +260,7 @@ public List submitTransaction(Duration timeout) { * sub-responses for each operation in the batch. * * @throws IllegalStateException If no operations have been added to the batch. - * @throws TableServiceErrorException if any operation within the batch fails. See the documentation for the client + * @throws TableServiceException if any operation within the batch fails. See the documentation for the client * methods in {@link TableClient} to understand the conditions that may cause a given operation to fail. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java index 09570003ff9f2..7540b6828f86b 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableClient.java @@ -10,7 +10,7 @@ import com.azure.core.util.Context; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableEntity; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; import java.time.Duration; @@ -93,7 +93,7 @@ public TableBatch createBatch(String partitionKey) { /** * Creates the table within the Tables service. * - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void create() { @@ -105,7 +105,7 @@ public void create() { * * @param timeout Duration to wait for the operation to complete. * - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void create(Duration timeout) { @@ -120,7 +120,7 @@ public void create(Duration timeout) { * * @return The HTTP response. * - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createWithResponse(Duration timeout, Context context) { @@ -132,7 +132,7 @@ public Response createWithResponse(Duration timeout, Context context) { * * @param entity The entity to insert. * - * @throws TableServiceErrorException If an entity with the same partition key and row key already exists within the + * @throws TableServiceException If an entity with the same partition key and row key already exists within the * table. * @throws IllegalArgumentException If the provided entity is invalid. */ @@ -147,7 +147,7 @@ public void createEntity(TableEntity entity) { * @param entity The entity to insert. * @param timeout Duration to wait for the operation to complete. * - * @throws TableServiceErrorException If an entity with the same partition key and row key already exists within the + * @throws TableServiceException If an entity with the same partition key and row key already exists within the * table. * @throws IllegalArgumentException If the provided entity is invalid. */ @@ -165,7 +165,7 @@ public void createEntity(TableEntity entity, Duration timeout) { * * @return The HTTP response. * - * @throws TableServiceErrorException If an entity with the same partition key and row key already exists within the + * @throws TableServiceException If an entity with the same partition key and row key already exists within the * table. * @throws IllegalArgumentException If the provided entity is invalid. */ @@ -183,7 +183,7 @@ public Response createEntityWithResponse(TableEntity entity, Duration time * @param entity The entity to upsert. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void upsertEntity(TableEntity entity) { @@ -205,7 +205,7 @@ public void upsertEntity(TableEntity entity) { * @param updateMode The type of update to perform if the entity already exits. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void upsertEntity(TableEntity entity, UpdateMode updateMode) { @@ -228,7 +228,7 @@ public void upsertEntity(TableEntity entity, UpdateMode updateMode) { * @param timeout Duration to wait for the operation to complete. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void upsertEntity(TableEntity entity, UpdateMode updateMode, Duration timeout) { @@ -254,7 +254,7 @@ public void upsertEntity(TableEntity entity, UpdateMode updateMode, Duration tim * @return The HTTP response. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response upsertEntityWithResponse(TableEntity entity, UpdateMode updateMode, Duration timeout, @@ -268,7 +268,7 @@ public Response upsertEntityWithResponse(TableEntity entity, UpdateMode up * @param entity The entity to update. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table. + * @throws TableServiceException If no entity with the same partition key and row key exists within the table. */ @ServiceMethod(returns = ReturnType.SINGLE) public void updateEntity(TableEntity entity) { @@ -286,7 +286,7 @@ public void updateEntity(TableEntity entity) { * @param updateMode which type of mode to execute * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table. + * @throws TableServiceException If no entity with the same partition key and row key exists within the table. */ @ServiceMethod(returns = ReturnType.SINGLE) public void updateEntity(TableEntity entity, UpdateMode updateMode) { @@ -306,7 +306,7 @@ public void updateEntity(TableEntity entity, UpdateMode updateMode) { * service. If the values do not match, the update will not occur and an exception will be thrown. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table, + * @throws TableServiceException If no entity with the same partition key and row key exists within the table, * or if {@code ifUnchanged} is {@code true} and the existing entity's eTag does not match that of the provided * entity. */ @@ -329,7 +329,7 @@ public void updateEntity(TableEntity entity, UpdateMode updateMode, boolean ifUn * @param timeout Duration to wait for the operation to complete. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table, + * @throws TableServiceException If no entity with the same partition key and row key exists within the table, * or if {@code ifUnchanged} is {@code true} and the existing entity's eTag does not match that of the provided * entity. */ @@ -355,7 +355,7 @@ public void updateEntity(TableEntity entity, UpdateMode updateMode, boolean ifUn * @return The HTTP response. * * @throws IllegalArgumentException If the provided entity is invalid. - * @throws TableServiceErrorException If no entity with the same partition key and row key exists within the table, + * @throws TableServiceException If no entity with the same partition key and row key exists within the table, * or if {@code ifUnchanged} is {@code true} and the existing entity's eTag does not match that of the provided * entity. */ @@ -368,7 +368,7 @@ public Response updateEntityWithResponse(TableEntity entity, UpdateMode up /** * Deletes the table within the Tables service. * - * @throws TableServiceErrorException If no table with this name exists within the service. + * @throws TableServiceException If no table with this name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void delete() { @@ -380,7 +380,7 @@ public void delete() { * * @param timeout Duration to wait for the operation to complete. * - * @throws TableServiceErrorException If no table with this name exists within the service. + * @throws TableServiceException If no table with this name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void delete(Duration timeout) { @@ -395,7 +395,7 @@ public void delete(Duration timeout) { * * @return The HTTP response. * - * @throws TableServiceErrorException If no table with this name exists within the service. + * @throws TableServiceException If no table with this name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteWithResponse(Duration timeout, Context context) { @@ -409,7 +409,7 @@ public Response deleteWithResponse(Duration timeout, Context context) { * @param rowKey The row key of the entity. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -426,7 +426,7 @@ public void deleteEntity(String partitionKey, String rowKey) { * the delete will not occur and an exception will be thrown. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table, or if {@code eTag} is not {@code null} and the existing entity's eTag does not match that of the provided * entity. */ @@ -445,7 +445,7 @@ public void deleteEntity(String partitionKey, String rowKey, String eTag) { * @param timeout Duration to wait for the operation to complete. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table, or if {@code eTag} is not {@code null} and the existing entity's eTag does not match that of the provided * entity. */ @@ -467,7 +467,7 @@ public void deleteEntity(String partitionKey, String rowKey, String eTag, Durati * @return The HTTP response. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table, or if {@code eTag} is not {@code null} and the existing entity's eTag does not match that of the provided * entity. */ @@ -482,7 +482,7 @@ public Response deleteEntityWithResponse(String partitionKey, String rowKe * * @return A paged iterable containing all entities within the table. * - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities() { @@ -501,7 +501,7 @@ public PagedIterable listEntities() { * @return A paged iterable containing matching entities within the table. * * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options) { @@ -517,7 +517,7 @@ public PagedIterable listEntities(ListEntitiesOptions options) { * @return A paged iterable containing all entities within the table. * * @throws IllegalArgumentException If an instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(Class resultType) { @@ -539,7 +539,7 @@ public PagedIterable listEntities(Class resultType * * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed, or if * an instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listEntities(ListEntitiesOptions options, Class resultType) { @@ -555,7 +555,7 @@ public PagedIterable listEntities(ListEntitiesOptions * @return The entity. * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -574,7 +574,7 @@ public TableEntity getEntity(String partitionKey, String rowKey) { * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if the * {@code select} OData query option is malformed. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -594,7 +594,7 @@ public TableEntity getEntity(String partitionKey, String rowKey, String select) * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if an * instance of the provided {@code resultType} can't be created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -616,7 +616,7 @@ public T getEntity(String partitionKey, String rowKey, C * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, if the * {@code select} OData query option is malformed, or if an instance of the provided {@code resultType} can't be * created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -636,7 +636,7 @@ public T getEntity(String partitionKey, String rowKey, S * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if the * {@code select} OData query option is malformed. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -659,7 +659,7 @@ public TableEntity getEntity(String partitionKey, String rowKey, String select, * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, if the * {@code select} OData query option is malformed, or if an instance of the provided {@code resultType} can't be * created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -681,7 +681,7 @@ public T getEntity(String partitionKey, String rowKey, S * * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, or if the * {@code select} OData query option is malformed. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) @@ -706,7 +706,7 @@ public Response getEntityWithResponse(String partitionKey, String r * @throws IllegalArgumentException If the provided partition key or row key are {@code null} or empty, if the * {@code select} OData query option is malformed, or if an instance of the provided {@code resultType} can't be * created. - * @throws TableServiceErrorException If no entity with the provided partition key and row key exists within the + * @throws TableServiceException If no entity with the provided partition key and row key exists within the * table. */ @ServiceMethod(returns = ReturnType.SINGLE) diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java index 405d2a09dda85..e5474d208b292 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceAsyncClient.java @@ -29,7 +29,7 @@ import com.azure.data.tables.implementation.models.TableResponseProperties; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableItem; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import reactor.core.publisher.Mono; import java.net.URI; @@ -135,7 +135,7 @@ public TableAsyncClient getTableClient(String tableName) { * @param tableName The name of the table to create. * @return An empty reactive result. * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono createTable(String tableName) { @@ -148,7 +148,7 @@ public Mono createTable(String tableName) { * @param tableName The name of the table to create. * @return A reactive result containing the HTTP response. * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> createTableWithResponse(String tableName) { @@ -162,7 +162,7 @@ Mono> createTableWithResponse(String tableName, Context context) try { return implementation.getTables().createWithResponseAsync(properties, null, ResponseFormat.RETURN_NO_CONTENT, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, null)); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -194,11 +194,11 @@ public Mono> createTableIfNotExistsWithResponse(String tableName) } Mono> createTableIfNotExistsWithResponse(String tableName, Context context) { - return createTableWithResponse(tableName, context).onErrorResume(e -> e instanceof TableServiceErrorException - && ((TableServiceErrorException) e).getResponse() != null - && ((TableServiceErrorException) e).getResponse().getStatusCode() == 409, + return createTableWithResponse(tableName, context).onErrorResume(e -> e instanceof TableServiceException + && ((TableServiceException) e).getResponse() != null + && ((TableServiceException) e).getResponse().getStatusCode() == 409, e -> { - HttpResponse response = ((TableServiceErrorException) e).getResponse(); + HttpResponse response = ((TableServiceException) e).getResponse(); return Mono.just(new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), null)); }); @@ -210,7 +210,7 @@ Mono> createTableIfNotExistsWithResponse(String tableName, Contex * @param tableName The name of the table to delete. * @return An empty reactive result. * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If no table with the provided name exists within the service. + * @throws TableServiceException If no table with the provided name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono deleteTable(String tableName) { @@ -223,7 +223,7 @@ public Mono deleteTable(String tableName) { * @param tableName The name of the table to delete. * @return A reactive result containing the HTTP response. * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If no table with the provided name exists within the service. + * @throws TableServiceException If no table with the provided name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Mono> deleteTableWithResponse(String tableName) { @@ -235,7 +235,7 @@ Mono> deleteTableWithResponse(String tableName, Context context) try { return implementation.getTables().deleteWithResponseAsync(tableName, null, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .map(response -> new SimpleResponse<>(response, null)); } catch (RuntimeException ex) { return monoError(logger, ex); @@ -262,7 +262,7 @@ public PagedFlux listTables() { * * @return A paged reactive result containing matching tables within the account. * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedFlux listTables(ListTablesOptions options) { @@ -298,7 +298,7 @@ private Mono> listTables(String nextTableName, Context try { return implementation.getTables().queryWithResponseAsync(null, nextTableName, queryOptions, context) - .onErrorMap(TableUtils::mapThrowableToTableServiceErrorException) + .onErrorMap(TableUtils::mapThrowableToTableServiceException) .flatMap(response -> { TableQueryResponse tableQueryResponse = response.getValue(); diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java index 45abbbc2627e3..683543da925c2 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/TableServiceClient.java @@ -10,7 +10,7 @@ import com.azure.core.util.Context; import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableItem; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import java.time.Duration; @@ -80,7 +80,7 @@ public TableClient getTableClient(String tableName) { * @param tableName The name of the table to create. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void createTable(String tableName) { @@ -94,7 +94,7 @@ public void createTable(String tableName) { * @param timeout Duration to wait for the operation to complete. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void createTable(String tableName, Duration timeout) { @@ -111,7 +111,7 @@ public void createTable(String tableName, Duration timeout) { * @return The HTTP response. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If a table with the same name already exists within the service. + * @throws TableServiceException If a table with the same name already exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response createTableWithResponse(String tableName, Duration timeout, Context context) { @@ -165,7 +165,7 @@ public Response createTableIfNotExistsWithResponse(String tableName, Durat * @param tableName The name of the table to delete. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If no table with the provided name exists within the service. + * @throws TableServiceException If no table with the provided name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable(String tableName) { @@ -179,7 +179,7 @@ public void deleteTable(String tableName) { * @param timeout Duration to wait for the operation to complete. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If no table with the provided name exists within the service. + * @throws TableServiceException If no table with the provided name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public void deleteTable(String tableName, Duration timeout) { @@ -196,7 +196,7 @@ public void deleteTable(String tableName, Duration timeout) { * @return The HTTP response. * * @throws IllegalArgumentException If {@code tableName} is {@code null} or empty. - * @throws TableServiceErrorException If no table with the provided name exists within the service. + * @throws TableServiceException If no table with the provided name exists within the service. */ @ServiceMethod(returns = ReturnType.SINGLE) public Response deleteTableWithResponse(String tableName, Duration timeout, Context context) { @@ -208,7 +208,7 @@ public Response deleteTableWithResponse(String tableName, Duration timeout * * @return A paged iterable containing all tables within the account. * - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables() { @@ -226,7 +226,7 @@ public PagedIterable listTables() { * @return A paged iterable containing matching tables within the account. * * @throws IllegalArgumentException If one or more of the OData query options in {@code options} is malformed. - * @throws TableServiceErrorException If the request is rejected by the service. + * @throws TableServiceException If the request is rejected by the service. */ @ServiceMethod(returns = ReturnType.COLLECTION) public PagedIterable listTables(ListTablesOptions options) { diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java index 68ee61066eaaa..e740ba6c7e9bb 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/implementation/TableUtils.java @@ -2,10 +2,11 @@ // Licensed under the MIT License. package com.azure.data.tables.implementation; +import com.azure.data.tables.implementation.models.TableServiceErrorException; import com.azure.data.tables.implementation.models.TableServiceErrorOdataError; import com.azure.data.tables.implementation.models.TableServiceErrorOdataErrorMessage; import com.azure.data.tables.models.TableServiceError; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; /** * A class containing utility methods for the Azure Data Tables library. @@ -30,7 +31,6 @@ public static TableServiceError toTableServiceError( com.azure.data.tables.implementation.models.TableServiceError tableServiceError) { String errorCode = null; - String languageCode = null; String errorMessage = null; if (tableServiceError != null) { @@ -41,43 +41,37 @@ public static TableServiceError toTableServiceError( TableServiceErrorOdataErrorMessage odataErrorMessage = odataError.getMessage(); if (odataErrorMessage != null) { - languageCode = odataErrorMessage.getLang(); errorMessage = odataErrorMessage.getValue(); } } } - return new TableServiceError(errorCode, languageCode, errorMessage); + return new TableServiceError(errorCode, errorMessage); } /** - * Convert an implementation {@link com.azure.data.tables.implementation.models.TableServiceErrorException} to a a - * public {@link TableServiceErrorException}. + * Convert an implementation {@link TableServiceErrorException} to a public {@link TableServiceException}. * - * @param exception The {@link com.azure.data.tables.implementation.models.TableServiceErrorException}. + * @param exception The {@link TableServiceErrorException}. * - * @return The {@link TableServiceErrorException} to be thrown. + * @return The {@link TableServiceException} to be thrown. */ - public static TableServiceErrorException toTableServiceErrorException( - com.azure.data.tables.implementation.models.TableServiceErrorException exception) { - - return new TableServiceErrorException(exception.getMessage(), exception.getResponse(), + public static TableServiceException toTableServiceException(TableServiceErrorException exception) { + return new TableServiceException(exception.getMessage(), exception.getResponse(), toTableServiceError(exception.getValue())); } /** - * Maps a {@link Throwable} to {@link TableServiceErrorException} if it's an instance of - * {@link com.azure.data.tables.implementation.models.TableServiceErrorException}, else it returns the original - * throwable. + * Map a {@link Throwable} to {@link TableServiceException} if it's an instance of + * {@link TableServiceErrorException}, else it returns the original throwable. * * @param throwable A throwable. * - * @return A Throwable that is either an instance of {@link TableServiceErrorException} or the original throwable. + * @return A Throwable that is either an instance of {@link TableServiceException} or the original throwable. */ - public static Throwable mapThrowableToTableServiceErrorException(Throwable throwable) { - if (throwable instanceof com.azure.data.tables.implementation.models.TableServiceErrorException) { - return toTableServiceErrorException( - (com.azure.data.tables.implementation.models.TableServiceErrorException) throwable); + public static Throwable mapThrowableToTableServiceException(Throwable throwable) { + if (throwable instanceof TableServiceErrorException) { + return toTableServiceException((TableServiceErrorException) throwable); } else { return throwable; } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableErrorCode.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableErrorCode.java index fb5a5a0527d4d..dafaf4680f0ed 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableErrorCode.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableErrorCode.java @@ -6,9 +6,59 @@ import com.azure.core.util.ExpandableStringEnum; /** - * Defines values for error codes returned from the Tables service. + * Defines values for error codes returned from the Tables service. For detailed information about what each error + * code means and their accompanying status codes, visit the following page: + * Table service error codes */ -public class TableErrorCode extends ExpandableStringEnum { +public final class TableErrorCode extends ExpandableStringEnum { + /** + * Static value {@code AuthorizationResourceTypeMismatch}. + */ + public static final TableErrorCode AUTHORIZATION_RESOURCE_TYPE_MISMATCH = + fromString("AuthorizationResourceTypeMismatch"); + + /** + * Static value {@code AuthorizationPermissionMismatch}. + */ + public static final TableErrorCode AUTHORIZATION_PERMISSION_MISMATCH = + fromString("AuthorizationPermissionMismatch"); + + /** + * Static value {@code XMethodNotUsingPost}. + */ + public static final TableErrorCode X_METHOD_NOT_USING_POST = fromString("XMethodNotUsingPost"); + + /** + * Static value {@code XMethodIncorrectValue}. + */ + public static final TableErrorCode X_METHOD_INCORRECT_VALUE = fromString("XMethodIncorrectValue"); + + /** + * Static value {@code XMethodIncorrectCount}. + */ + public static final TableErrorCode X_METHOD_INCORRECT_COUNT = fromString("XMethodIncorrectCount"); + + /** + * Static value {@code TableHasNoProperties}. + */ + public static final TableErrorCode TABLE_HAS_NO_PROPERTIES = fromString("TableHasNoProperties"); + + /** + * Static value {@code DuplicatePropertiesSpecified}. + */ + public static final TableErrorCode DUPLICATE_PROPERTIES_SPECIFIED = + fromString("DuplicatePropertiesSpecified"); + + /** + * Static value {@code TableHasNoSuchProperty}. + */ + public static final TableErrorCode TABLE_HAS_NO_SUCH_PROPERTY = fromString("TableHasNoSuchProperty"); + + /** + * Static value {@code DuplicateKeyPropertySpecified}. + */ + public static final TableErrorCode DUPLICATE_KEY_PROPERTY_SPECIFIED = + fromString("DuplicateKeyPropertySpecified"); /** * Static value {@code TableAlreadyExists}. @@ -21,9 +71,14 @@ public class TableErrorCode extends ExpandableStringEnum { public static final TableErrorCode TABLE_NOT_FOUND = fromString("TableNotFound"); /** - * Static value {@code InvalidTableName}. + * Static value {@code TableNotFound}. + */ + public static final TableErrorCode RESOURCE_NOT_FOUND = fromString("ResourceNotFound"); + + /** + * Static value {@code EntityNotFound}. */ - public static final TableErrorCode INVALID_TABLE_NAME = fromString("InvalidTableName"); + public static final TableErrorCode ENTITY_NOT_FOUND = fromString("EntityNotFound"); /** * Static value {@code EntityAlreadyExists}. @@ -31,20 +86,191 @@ public class TableErrorCode extends ExpandableStringEnum { public static final TableErrorCode ENTITY_ALREADY_EXISTS = fromString("EntityAlreadyExists"); /** - * Static value {@code EntityNotFound}. + * Static value {@code PartitionKeyNotSpecified}. */ - public static final TableErrorCode ENTITY_NOT_FOUND = fromString("EntityNotFound"); + public static final TableErrorCode PARTITION_KEY_NOT_SPECIFIED = fromString("PartitionKeyNotSpecified"); /** - * Static value {@code InvalidPkOrRkName}. + * Static value {@code OperatorInvalid}. */ - public static final TableErrorCode INVALID_PK_OR_RK_NAME = fromString("InvalidPkOrRkName"); + public static final TableErrorCode OPERATOR_INVALID = fromString("OperatorInvalid"); + + /** + * Static value {@code UpdateConditionNotSatisfied}. + */ + public static final TableErrorCode UPDATE_CONDITION_NOT_SATISFIED = fromString("UpdateConditionNotSatisfied"); + + /** + * Static value {@code PropertiesNeedValue}. + */ + public static final TableErrorCode PROPERTIES_NEED_VALUE = fromString("PropertiesNeedValue"); + + /** + * Static value {@code PartitionKeyPropertyCannotBeUpdated}. + */ + public static final TableErrorCode PARTITION_KEY_PROPERTY_CANNOT_BE_UPDATED = + fromString("PartitionKeyPropertyCannotBeUpdated"); + + /** + * Static value {@code TooManyProperties}. + */ + public static final TableErrorCode TOO_MANY_PROPERTIES = fromString("TooManyProperties"); + + /** + * Static value {@code EntityTooLarge}. + */ + public static final TableErrorCode ENTITY_TOO_LARGE = fromString("EntityTooLarge"); + + /** + * Static value {@code PropertyValueTooLarge}. + */ + public static final TableErrorCode PROPERTY_VALUE_TOO_LARGE = fromString("PropertyValueTooLarge"); + + /** + * Static value {@code KeyValueTooLarge}. + */ + public static final TableErrorCode KEY_VALUE_TOO_LARGE = fromString("KeyValueTooLarge"); + + /** + * Static value {@code InvalidValueType}. + */ + public static final TableErrorCode INVALID_VALUE_TYPE = fromString("InvalidValueType"); + + /** + * Static value {@code TableBeingDeleted}. + */ + public static final TableErrorCode TABLE_BEING_DELETED = fromString("TableBeingDeleted"); + + /** + * Static value {@code PrimaryKeyPropertyIsInvalidType}. + */ + public static final TableErrorCode PRIMARY_KEY_PROPERTY_IS_INVALID_TYPE = + fromString("PrimaryKeyPropertyIsInvalidType"); + + /** + * Static value {@code PropertyNameTooLong}. + */ + public static final TableErrorCode PROPERTY_NAME_TOO_LONG = fromString("PropertyNameTooLong"); + + /** + * Static value {@code PropertyNameInvalid}. + */ + public static final TableErrorCode PROPERTY_NAME_INVALID = fromString("PropertyNameInvalid"); + + /** + * Static value {@code InvalidDuplicateRow}. + */ + public static final TableErrorCode INVALID_DUPLICATE_ROW = fromString("InvalidDuplicateRow"); + + /** + * Static value {@code CommandsInBatchActOnDifferentPartitions}. + */ + public static final TableErrorCode COMMANDS_IN_BATCH_ACT_ON_DIFFERENT_PARTITIONS = + fromString("CommandsInBatchActOnDifferentPartitions"); + + /** + * Static value {@code JsonFormatNotSupported}. + */ + public static final TableErrorCode JSON_FORMAT_NOT_SUPPORTED = fromString("JsonFormatNotSupported"); + + /** + * Static value {@code AtomFormatNotSupported}. + */ + public static final TableErrorCode ATOM_FORMAT_NOT_SUPPORTED = fromString("AtomFormatNotSupported"); + + /** + * Static value {@code JsonVerboseFormatNotSupported}. + */ + public static final TableErrorCode JSON_VERBOSE_FORMAT_NOT_SUPPORTED = + fromString("JsonVerboseFormatNotSupported"); + + /** + * Static value {@code MediaTypeNotSupported}. + */ + public static final TableErrorCode MEDIA_TYPE_NOT_SUPPORTED = fromString("MediaTypeNotSupported"); + + /** + * Static value {@code MethodNotAllowed}. + */ + public static final TableErrorCode METHOD_NOT_ALLOWED = fromString("MethodNotAllowed"); + + /** + * Static value {@code ContentLengthExceeded}. + */ + public static final TableErrorCode CONTENT_LENGTH_EXCEEDED = fromString("ContentLengthExceeded"); + + /** + * Static value {@code AccountIOPSLimitExceeded}. + */ + public static final TableErrorCode ACCOUNT_IOPS_LIMIT_EXCEEDED = fromString("AccountIOPSLimitExceeded"); + + /** + * Static value {@code CannotCreateTableWithIOPSGreaterThanMaxAllowedPerTable}. + */ + public static final TableErrorCode CANNOT_CREATE_TABLE_WITH_IOPS_GREATER_THAN_MAX_ALLOWED_PER_TABLE = + fromString("CannotCreateTableWithIOPSGreaterThanMaxAllowedPerTable"); + + /** + * Static value {@code PerTableIOPSIncrementLimitReached}. + */ + public static final TableErrorCode PER_TABLE_IOPS_INCREMENT_LIMIT_REACHED = + fromString("PerTableIOPSIncrementLimitReached"); + + /** + * Static value {@code PerTableIOPSDecrementLimitReached}. + */ + public static final TableErrorCode PER_TABLE_IOPS_DECREMENT_LIMIT_REACHED = + fromString("PerTableIOPSDecrementLimitReached"); + + /** + * Static value {@code SettingIOPSForATableInProvisioningNotAllowed}. + */ + public static final TableErrorCode SETTING_IOPS_FOR_A_TABLE_IN_PROVISIONING_NOT_ALLOWED = + fromString("SettingIOPSForATableInProvisioningNotAllowed"); + + /** + * Static value {@code PartitionKeyEqualityComparisonExpected}. + */ + public static final TableErrorCode PARTITION_KEY_EQUALITY_COMPARISON_EXPECTED = + fromString("PartitionKeyEqualityComparisonExpected"); + + /** + * Static value {@code PartitionKeySpecifiedMoreThanOnce}. + */ + public static final TableErrorCode PARTITION_KEY_SPECIFIED_MORE_THAN_ONCE = + fromString("PartitionKeySpecifiedMoreThanOnce"); + + /** + * Static value {@code InvalidInput}. + */ + public static final TableErrorCode INVALID_INPUT = fromString("InvalidInput"); + + /** + * Static value {@code NotImplemented}. + */ + public static final TableErrorCode NOT_IMPLEMENTED = fromString("NotImplemented"); + + /** + * Static value {@code OperationTimedOut}. + */ + public static final TableErrorCode OPERATION_TIMED_OUT = fromString("OperationTimedOut"); + + /** + * Static value {@code OutOfRangeInput}. + */ + public static final TableErrorCode OUT_OF_RANGE_INPUT = fromString("OutOfRangeInput"); + + /** + * Static value {@code Forbidden}. + */ + public static final TableErrorCode FORBIDDEN = fromString("Forbidden"); /** * Returns the {@code TableErrorCode} constant with the provided name, or {@code null} if no {@code TableErrorCode} * has the provided name. * * @param name The name of the error. + * * @return The {@code TableErrorCode} value having the provided name. */ public static TableErrorCode fromString(String name) { diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceError.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceError.java index ab3c296eb2edb..8dd84cbd9e292 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceError.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceError.java @@ -11,11 +11,6 @@ public final class TableServiceError { */ private final String errorCode; - /* - * Language code of the error message. - */ - private final String languageCode; - /* * The error message. */ @@ -25,12 +20,10 @@ public final class TableServiceError { * Create an instance of {@link TableServiceError}. * * @param errorCode The service error code. - * @param languageCode Language code of the error message. * @param errorMessage The error message. */ - public TableServiceError(String errorCode, String languageCode, String errorMessage) { + public TableServiceError(String errorCode, String errorMessage) { this.errorCode = errorCode; - this.languageCode = languageCode; this.errorMessage = errorMessage; } @@ -39,17 +32,8 @@ public TableServiceError(String errorCode, String languageCode, String errorMess * * @return The service error code. */ - public String getErrorCode() { - return this.errorCode; - } - - /** - * Get the language code of the error message. - * - * @return The language code of the error message. - */ - public String getLanguageCode() { - return this.languageCode; + public TableErrorCode getErrorCode() { + return TableErrorCode.fromString(errorCode); } /** diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceErrorException.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceException.java similarity index 68% rename from sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceErrorException.java rename to sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceException.java index 8cf5de624c8ae..474c538a74868 100644 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceErrorException.java +++ b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableServiceException.java @@ -8,25 +8,25 @@ /** * Exception thrown for an invalid response with {@link TableServiceError} information. */ -public final class TableServiceErrorException extends HttpResponseException { +public final class TableServiceException extends HttpResponseException { /** - * Initializes a new instance of the {@link TableServiceErrorException} class. + * Initializes a new instance of the {@link TableServiceException} class. * * @param message The exception message or the response content if a message is not available. * @param response The HTTP response. */ - public TableServiceErrorException(String message, HttpResponse response) { + public TableServiceException(String message, HttpResponse response) { super(message, response); } /** - * Initializes a new instance of the {@link TableServiceErrorException} class. + * Initializes a new instance of the {@link TableServiceException} class. * * @param message The exception message or the response content if a message is not available. * @param response The HTTP response. * @param value The deserialized response value. */ - public TableServiceErrorException(String message, HttpResponse response, TableServiceError value) { + public TableServiceException(String message, HttpResponse response, TableServiceError value) { super(message, response, value); } diff --git a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableStorageException.java b/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableStorageException.java deleted file mode 100644 index 2abde14810f12..0000000000000 --- a/sdk/tables/azure-data-tables/src/main/java/com/azure/data/tables/models/TableStorageException.java +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.data.tables.models; - -import com.azure.core.exception.HttpResponseException; -import com.azure.core.http.HttpResponse; -import static com.azure.storage.common.implementation.Constants.HeaderConstants.ERROR_CODE; - -/** - * A {@code TableStorageException} is thrown whenever the Tables service successfully returns an error code that is not - * 200-level. Users can inspect the status code and error code to determine the cause of the error response. The - * exception message may also contain more detailed information depending on the type of error. The user may also - * inspect the raw HTTP response or call {@link #toString()} to get the full payload of the error response if present. - */ -public class TableStorageException extends HttpResponseException { - - /** - * Constructs a {@code TableStorageException}. - * - * @param message The exception message or the response content if a message is not available. - * @param response The {@link HttpResponse}. - * @param value The error code of the exception. - */ - public TableStorageException(String message, HttpResponse response, Object value) { - super(message, response, value); - } - - /** - * Gets the error code returned by the service. - * - * @return The error code returned by the service. - */ - public TableErrorCode getErrorCode() { - return TableErrorCode.fromString(super.getResponse().getHeaders().getValue(ERROR_CODE)); - } - - /** - * Gets the message returned by the service. - * - * @return The message returned by the service. - */ - public String getServiceMessage() { - return super.getMessage(); - } - - /** - * Gets the status code of the response. - * - * @return The status code of the response. - */ - public int getStatusCode() { - return super.getResponse().getStatusCode(); - } -} diff --git a/sdk/tables/azure-data-tables/src/samples/java/ReadmeSamples.java b/sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/ReadmeSamples.java similarity index 94% rename from sdk/tables/azure-data-tables/src/samples/java/ReadmeSamples.java rename to sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/ReadmeSamples.java index eaf6a7599f50b..e73bbda9178d9 100644 --- a/sdk/tables/azure-data-tables/src/samples/java/ReadmeSamples.java +++ b/sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/ReadmeSamples.java @@ -7,7 +7,7 @@ import com.azure.data.tables.models.ListTablesOptions; import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableItem; -import com.azure.data.tables.models.TableStorageException; +import com.azure.data.tables.models.TableServiceException; import java.util.Map; @@ -67,7 +67,7 @@ public void constructServiceClient() { /** * Code sample for creating a table. - * @throws TableStorageException if the table exists. + * @throws TableServiceException if the table exists. */ public void createTable() { tableServiceClient.createTable(tableName); @@ -118,7 +118,7 @@ public void retrieveTableClient() { /** * Code sample for creating an entity. - * @throws TableStorageException if the entity exists. + * @throws TableServiceException if the entity exists. */ public void createEntity() { TableEntity entity = new TableEntity(partitionKey, rowKey) @@ -160,8 +160,8 @@ public void accessErrorInfo() { // Now attempt to create the same table unconditionally. try { tableServiceClient.createTable(tableName); - } catch (TableStorageException e) { - System.out.println(e.getStatusCode()); // 409 + } catch (TableServiceException e) { + System.out.println(e.getResponse().getStatusCode()); // 409 } } } diff --git a/sdk/tables/azure-data-tables/src/samples/java/TableServiceAsyncClientCodeSnippets.java b/sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/TableServiceAsyncClientCodeSnippets.java similarity index 100% rename from sdk/tables/azure-data-tables/src/samples/java/TableServiceAsyncClientCodeSnippets.java rename to sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/TableServiceAsyncClientCodeSnippets.java diff --git a/sdk/tables/azure-data-tables/src/samples/java/TableServiceClientCodeSnippets.java b/sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/TableServiceClientCodeSnippets.java similarity index 84% rename from sdk/tables/azure-data-tables/src/samples/java/TableServiceClientCodeSnippets.java rename to sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/TableServiceClientCodeSnippets.java index 61fb08eb714ec..059556a2dd954 100644 --- a/sdk/tables/azure-data-tables/src/samples/java/TableServiceClientCodeSnippets.java +++ b/sdk/tables/azure-data-tables/src/samples/java/com/azure/data/tables/TableServiceClientCodeSnippets.java @@ -9,7 +9,7 @@ import com.azure.data.tables.models.TableEntity; import com.azure.data.tables.models.TableErrorCode; import com.azure.data.tables.models.TableItem; -import com.azure.data.tables.models.TableStorageException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; /** @@ -27,11 +27,9 @@ public void createTable() { .buildClient(); try { tableServiceClient.createTable("OfficeSupplies"); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.TABLE_ALREADY_EXISTS) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.TABLE_ALREADY_EXISTS) { System.err.println("Create Table Unsuccessful. Table already exists."); - } else if (e.getErrorCode() == TableErrorCode.INVALID_TABLE_NAME) { - System.err.println("Create Table Unsuccessful. Table name invalid"); } else { System.err.println("Create Table Unsuccessful. " + e); } @@ -48,8 +46,8 @@ public void deleteTable() { try { tableServiceClient.deleteTable("OfficeSupplies"); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.TABLE_NOT_FOUND) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.TABLE_NOT_FOUND) { System.err.println("Delete Table Unsuccessful. Table not found."); } else { System.err.println("Delete Table Unsuccessful. Error: " + e); @@ -69,7 +67,7 @@ public void listTables() { try { PagedIterable tablePagedIterable = tableServiceClient.listTables(options); - } catch (TableStorageException e) { + } catch (TableServiceException e) { System.err.println("Table Query Unsuccessful. Error: " + e); } } @@ -87,11 +85,9 @@ private void createEntity() { try { tableClient.createEntity(entity); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.ENTITY_ALREADY_EXISTS) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.ENTITY_ALREADY_EXISTS) { System.err.println("Create Entity Unsuccessful. Entity already exists."); - } else if (e.getErrorCode() == TableErrorCode.INVALID_PK_OR_RK_NAME) { - System.err.println("Create Table Unsuccessful. Row key or Partition key is invalid."); } else { System.err.println("Create Entity Unsuccessful. " + e); } @@ -114,8 +110,8 @@ private void deleteEntity() { //supplying the eTag means the eTags must match to delete tableClient.deleteEntity(partitionKey, rowKey, entity.getETag()); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { System.err.println("Delete Entity Unsuccessful. Entity not found."); } else { System.err.println("Delete Entity Unsuccessful. Error: " + e); @@ -140,8 +136,8 @@ private void updateEntity() { //default is for UpdateMode is UpdateMode.MERGE, which means it merges if exists; fails if not //ifUnchanged being false means the eTags must not match tableClient.updateEntity(entity); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { System.err.println("Cannot find entity. Update unsuccessful"); } else { System.err.println("Update Entity Unsuccessful. Error: " + e); @@ -166,8 +162,8 @@ private void upsertEntity() { //default is for UpdateMode is UpdateMode.REPLACE, which means it replaces if exists; inserts if not //always upsert because if no ifUnchanged boolean present the "*" in request. tableClient.upsertEntity(entity, UpdateMode.REPLACE); - } catch (TableStorageException e) { - if (e.getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { + } catch (TableServiceException e) { + if (e.getValue().getErrorCode() == TableErrorCode.ENTITY_NOT_FOUND) { System.err.println("Cannot find entity. Upsert unsuccessful"); } else { System.err.println("Upsert Entity Unsuccessful. Error: " + e); @@ -189,7 +185,7 @@ private void listEntity() { .setSelect("Seller, Price"); try { PagedIterable tableEntities = tableClient.listEntities(options); - } catch (TableStorageException e) { + } catch (TableServiceException e) { System.err.println("Query Table Entities Unsuccessful. Error: " + e); } } @@ -207,7 +203,7 @@ public void entityExists() { String rowKey = "crayolaMarkers"; try { TableEntity entity = tableClient.getEntity(partitionKey, rowKey); - } catch (TableStorageException e) { + } catch (TableServiceException e) { System.err.println("Get Entity Unsuccessful. Entity may not exist: " + e); } } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java index 1e3650a737a2d..db58294e63abb 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceAsyncClientTest.java @@ -10,7 +10,7 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.test.TestBase; import com.azure.data.tables.models.ListTablesOptions; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; @@ -79,8 +79,8 @@ void serviceCreateTableFailsIfExistsAsync() { //Act & Assert StepVerifier.create(serviceClient.createTable(tableName)) - .expectErrorMatches(e -> e instanceof TableServiceErrorException - && ((TableServiceErrorException) e).getResponse().getStatusCode() == 409) + .expectErrorMatches(e -> e instanceof TableServiceException + && ((TableServiceException) e).getResponse().getStatusCode() == 409) .verify(); } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java index c500ecde63189..f90c8afbfd5e5 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TableServiceClientTest.java @@ -9,7 +9,7 @@ import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.test.TestBase; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -82,7 +82,7 @@ void serviceCreateTableFailsIfExists() { serviceClient.createTable(tableName); // Act & Assert - Assertions.assertThrows(TableServiceErrorException.class, + Assertions.assertThrows(TableServiceException.class, () -> serviceClient.createTable(tableName)); } diff --git a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TablesAsyncClientTest.java b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TablesAsyncClientTest.java index ac56e022e279f..db82725c08824 100644 --- a/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TablesAsyncClientTest.java +++ b/sdk/tables/azure-data-tables/src/test/java/com/azure/data/tables/TablesAsyncClientTest.java @@ -15,7 +15,7 @@ import com.azure.data.tables.models.BatchOperationResponse; import com.azure.data.tables.models.ListEntitiesOptions; import com.azure.data.tables.models.TableEntity; -import com.azure.data.tables.models.TableServiceErrorException; +import com.azure.data.tables.models.TableServiceException; import com.azure.data.tables.models.UpdateMode; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -763,7 +763,7 @@ void batchAsyncWithFailingOperation() { // Act & Assert StepVerifier.create(batch.submitTransactionWithResponse()) - .expectErrorMatches(e -> e instanceof TableServiceErrorException + .expectErrorMatches(e -> e instanceof TableServiceException && e.getMessage().contains("An operation within the batch failed") && e.getMessage().contains("The failed operation was") && e.getMessage().contains("DeleteEntity")