public class CosmosException
extends com.azure.core.exception.AzureException
Errors coming from the service during normal execution are converted to CosmosException before returning to the application with the following exception:
When a BE error is encountered during a QueryIterable<T> iteration, an IllegalStateException is thrown instead of CosmosException.
When a transport level error happens that request is not able to reach the service, an IllegalStateException is thrown instead of CosmosException.
Modifier | Constructor and Description |
---|---|
protected |
CosmosException(int statusCode,
com.azure.cosmos.implementation.CosmosError cosmosErrorResource,
Map<String,String> responseHeaders)
Creates a new instance of the CosmosException class.
|
protected |
CosmosException(int statusCode,
Exception innerException)
Creates a new instance of the CosmosException class.
|
protected |
CosmosException(int statusCode,
String errorMessage)
Creates a new instance of the CosmosException class.
|
protected |
CosmosException(int statusCode,
String message,
Map<String,String> responseHeaders,
Throwable cause) |
protected |
CosmosException(String message,
Exception exception,
Map<String,String> responseHeaders,
int statusCode,
String resourceAddress)
Creates a new instance of the CosmosException class.
|
protected |
CosmosException(String resourceAddress,
int statusCode,
com.azure.cosmos.implementation.CosmosError cosmosErrorResource,
Map<String,String> responseHeaders)
Creates a new instance of the CosmosException class.
|
protected |
CosmosException(String resourceAddress,
int statusCode,
com.azure.cosmos.implementation.CosmosError cosmosErrorResource,
Map<String,String> responseHeaders,
Throwable cause)
Creates a new instance of the CosmosException class.
|
Modifier and Type | Method and Description |
---|---|
String |
getActivityId()
Gets the activity ID associated with the request.
|
CosmosDiagnostics |
getDiagnostics()
Gets the Cosmos Diagnostic Statistics associated with this exception.
|
String |
getMessage() |
double |
getRequestCharge()
Gets the request charge as request units (RU) consumed by the operation.
|
Map<String,String> |
getResponseHeaders()
Gets the response headers as key-value pairs
|
Duration |
getRetryAfterDuration()
Gets the recommended time duration after which the client can retry failed
requests
|
int |
getStatusCode()
Gets the http status code.
|
int |
getSubStatusCode()
Gets the sub status code.
|
String |
toString() |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
protected CosmosException(int statusCode, String message, Map<String,String> responseHeaders, Throwable cause)
protected CosmosException(int statusCode, String errorMessage)
statusCode
- the http status code of the response.errorMessage
- the error message.protected CosmosException(int statusCode, Exception innerException)
statusCode
- the http status code of the response.innerException
- the original exception.protected CosmosException(int statusCode, com.azure.cosmos.implementation.CosmosError cosmosErrorResource, Map<String,String> responseHeaders)
statusCode
- the http status code of the response.cosmosErrorResource
- the error resource object.responseHeaders
- the response headers.protected CosmosException(String resourceAddress, int statusCode, com.azure.cosmos.implementation.CosmosError cosmosErrorResource, Map<String,String> responseHeaders)
resourceAddress
- the address of the resource the request is associated with.statusCode
- the http status code of the response.cosmosErrorResource
- the error resource object.responseHeaders
- the response headers.protected CosmosException(String resourceAddress, int statusCode, com.azure.cosmos.implementation.CosmosError cosmosErrorResource, Map<String,String> responseHeaders, Throwable cause)
resourceAddress
- the address of the resource the request is associated with.statusCode
- the http status code of the response.cosmosErrorResource
- the error resource object.responseHeaders
- the response headers.cause
- the inner exceptionprotected CosmosException(String message, Exception exception, Map<String,String> responseHeaders, int statusCode, String resourceAddress)
message
- the string message.statusCode
- the http status code of the response.exception
- the exception object.responseHeaders
- the response headers.resourceAddress
- the address of the resource the request is associated with.public String getMessage()
getMessage
in class Throwable
public String getActivityId()
public int getStatusCode()
public int getSubStatusCode()
public Duration getRetryAfterDuration()
public Map<String,String> getResponseHeaders()
public CosmosDiagnostics getDiagnostics()
public double getRequestCharge()
For more information about the RU and factors that can impact the effective charges please visit Request Units in Azure Cosmos DB
Copyright © 2021 Microsoft Corporation. All rights reserved.