Dela via


DocumentClientException Class

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • com.microsoft.azure.documentdb.DocumentClientException

public class DocumentClientException
extends java.lang.Exception

This class defines a custom exception type for all operations on DocumentClient in the Azure Cosmos DB database service. Applications are expected to catch DocumentClientException and handle errors as appropriate when calling methods on DocumentClient.

Errors coming from the service during normal execution are converted to DocumentClientException before returning to the application with the following exception:

When a BE error is encountered during a QueryIterable iteration, an IllegalStateException is thrown instead of DocumentClientException.

When a transport level error happens that request is not able to reach the service, an IllegalStateException is thrown instead of DocumentClientException.

Constructor Summary

Constructor Description
DocumentClientException(int statusCode)

Creates a new instance of the DocumentClientException class.

DocumentClientException(int statusCode, Error errorResource, Map<String,String> responseHeaders)

Creates a new instance of the DocumentClientException class.

DocumentClientException(int statusCode, Exception innerException)

Creates a new instance of the DocumentClientException class.

DocumentClientException(int statusCode, Exception innerException, Map<String,String> responseHeaders)

Deprecated

this constructor is deprecated and is used internally only.

Creates a new instance of the DocumentClientException class.

DocumentClientException(int statusCode, String errorMessage)

Creates a new instance of the DocumentClientException class.

DocumentClientException(String resourceAddress, int statusCode, Error errorResource, Map<String,String> responseHeaders)

Creates a new instance of the DocumentClientException class.

Method Summary

Modifier and Type Method and Description
java.lang.String getActivityId()

Gets the activity ID associated with the request.

ClientSideRequestStatistics getClientSideRequestStatistics()

Gets the Client side request statistics associated with this exception.

Error getError()

Gets the error code associated with the exception.

java.lang.String getInnerErrorMessage()
java.lang.String getMessage()
java.lang.String getResourceAddress()

Gets the resource address associated with this exception.

java.util.Map<java.lang.String,java.lang.String> getResponseHeaders()

Gets the response headers as key-value pairs

long getRetryAfterInMilliseconds()

Gets the recommended time interval after which the client can retry failed requests

int getStatusCode()

Gets the http status code.

java.lang.Integer getSubStatusCode()

Gets the sub status code.

void setClientSideRequestStatistics(ClientSideRequestStatistics clientSideRequestStatistics)

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Methods inherited from java.lang.Throwable

java.lang.Throwable.addSuppressed java.lang.Throwable.fillInStackTrace java.lang.Throwable.getCause java.lang.Throwable.getLocalizedMessage java.lang.Throwable.getMessage java.lang.Throwable.getStackTrace java.lang.Throwable.getSuppressed java.lang.Throwable.initCause java.lang.Throwable.printStackTrace java.lang.Throwable.printStackTrace java.lang.Throwable.printStackTrace java.lang.Throwable.setStackTrace java.lang.Throwable.toString

Constructor Details

DocumentClientException

public DocumentClientException(int statusCode)

Creates a new instance of the DocumentClientException class.

Parameters:

statusCode - the http status code of the response.

DocumentClientException

public DocumentClientException(int statusCode, Error errorResource, Map responseHeaders)

Creates a new instance of the DocumentClientException class.

Parameters:

statusCode - the http status code of the response.
errorResource - the error resource object.
responseHeaders - the response headers.

DocumentClientException

public DocumentClientException(int statusCode, Exception innerException)

Creates a new instance of the DocumentClientException class.

Parameters:

statusCode - the http status code of the response.
innerException - the original exception.

DocumentClientException


public DocumentClientException(int statusCode, Exception innerException, Map responseHeaders)

Deprecated

this constructor is deprecated and is used internally only.

Creates a new instance of the DocumentClientException class.

Parameters:

statusCode - the http status code of the response.
innerException - the original exception.
responseHeaders - the response headers.

DocumentClientException

public DocumentClientException(int statusCode, String errorMessage)

Creates a new instance of the DocumentClientException class.

Parameters:

statusCode - the http status code of the response.
errorMessage - the error message.

DocumentClientException

public DocumentClientException(String resourceAddress, int statusCode, Error errorResource, Map responseHeaders)

Creates a new instance of the DocumentClientException class.

Parameters:

resourceAddress - the address of the resource the request is associated with.
statusCode - the http status code of the response.
errorResource - the error resource object.
responseHeaders - the response headers.

Method Details

getActivityId

public String getActivityId()

Gets the activity ID associated with the request.

Returns:

the activity ID.

getClientSideRequestStatistics

public ClientSideRequestStatistics getClientSideRequestStatistics()

Gets the Client side request statistics associated with this exception.

Returns:

Client side request statistics associated with this exception.

getError

public Error getError()

Gets the error code associated with the exception.

Returns:

the error.

getInnerErrorMessage

public String getInnerErrorMessage()

getMessage

public String getMessage()

Overrides:

DocumentClientException.getMessage()

getResourceAddress

public String getResourceAddress()

Gets the resource address associated with this exception.

Returns:

the resource address associated with this exception.

getResponseHeaders

public Map getResponseHeaders()

Gets the response headers as key-value pairs

Returns:

the response headers

getRetryAfterInMilliseconds

public long getRetryAfterInMilliseconds()

Gets the recommended time interval after which the client can retry failed requests

Returns:

the recommended time interval after which the client can retry failed requests.

getStatusCode

public int getStatusCode()

Gets the http status code.

Returns:

the status code.

getSubStatusCode

public Integer getSubStatusCode()

Gets the sub status code.

Returns:

the status code.

setClientSideRequestStatistics

public void setClientSideRequestStatistics(ClientSideRequestStatistics clientSideRequestStatistics)

Parameters:

clientSideRequestStatistics

Applies to