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

com.emc.vipr.client.exceptions.ServiceErrorException Maven / Gradle / Ivy

There is a newer version: 3.5.0.0
Show newest version
/*
 * Copyright (c) 2015 EMC Corporation
 * All Rights Reserved
 */
package com.emc.vipr.client.exceptions;

import com.emc.storageos.model.errorhandling.ServiceErrorRestRep;

public class ServiceErrorException extends ViPRHttpException {
    private final ServiceErrorRestRep serviceError;

    public ServiceErrorException(int httpStatus, ServiceErrorRestRep serviceError) {
        super(httpStatus);
        if (serviceError == null) {
            this.serviceError = new ServiceErrorRestRep();
        }
        else {
            this.serviceError = serviceError;
        }
    }

    public ServiceErrorException(ServiceErrorRestRep serviceError) {
        this(-1, serviceError);
    }

    @Override
    public String getLocalizedMessage() {
        String message = getDetailedMessage() == null || getDetailedMessage().isEmpty() ?
                getCodeDescription() : getDetailedMessage();
        return String.format("Error %s: %s", getCode(), message);
    }

    @Override
    public String getMessage() {
        return getLocalizedMessage();
    }

    public ServiceErrorRestRep getServiceError() {
        return serviceError;
    }

    public boolean isRetryable() {
        return getServiceError().isRetryable();
    }

    public int getCode() {
        return getServiceError().getCode();
    }

    public String getCodeDescription() {
        return getServiceError().getCodeDescription();
    }

    public String getDetailedMessage() {
        return getServiceError().getDetailedMessage();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy