All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.cosmos.ServiceUnavailableException Maven / Gradle / Ivy

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos;

import com.azure.cosmos.implementation.HttpConstants;
import com.azure.cosmos.implementation.RMResources;
import com.azure.cosmos.implementation.directconnectivity.HttpUtils;
import com.azure.cosmos.implementation.http.HttpHeaders;

import java.net.URI;
import java.util.Map;

public class ServiceUnavailableException extends CosmosClientException {
    ServiceUnavailableException() {
        this(RMResources.ServiceUnavailable);
    }

    public ServiceUnavailableException(CosmosError cosmosError,
                                       long lsn,
                                       String partitionKeyRangeId,
                                       Map responseHeaders) {
        super(HttpConstants.StatusCodes.SERVICE_UNAVAILABLE, cosmosError, responseHeaders);
        BridgeInternal.setLSN(this, lsn);
        BridgeInternal.setPartitionKeyRangeId(this, partitionKeyRangeId);
    }

    ServiceUnavailableException(String message) {
        this(message, null, null, null);
    }

    ServiceUnavailableException(String message, HttpHeaders headers, String requestUriString) {
        this(message, null, headers, requestUriString);
    }

    public ServiceUnavailableException(String message, HttpHeaders headers, URI requestUri) {
        this(message, headers, requestUri != null ? requestUri.toString() : null);
    }

    ServiceUnavailableException(Exception innerException) {
        this(RMResources.ServiceUnavailable, innerException, null, null);
    }

    public ServiceUnavailableException(String message,
                                       Exception innerException,
                                       HttpHeaders headers,
                                       String requestUriString) {
        super(String.format("%s: %s", RMResources.ServiceUnavailable, message),
            innerException,
            HttpUtils.asMap(headers),
            HttpConstants.StatusCodes.SERVICE_UNAVAILABLE,
            requestUriString);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy