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

com.emc.vipr.client.exceptions.ServiceErrorsException 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;
import java.util.ArrayList;
import java.util.List;

public class ServiceErrorsException extends ViPRException {

    private static final long serialVersionUID = 1L;

    private List serviceErrors;

    public ServiceErrorsException() {
        this(new ArrayList());
    }

    public ServiceErrorsException(List serviceErrors) {
        this.serviceErrors = serviceErrors;
    }

    @Override
    public String getLocalizedMessage() {
        StringBuilder sb = new StringBuilder();
        // Printf-style format strings should not lead to unexpected behavior at runtime
        // using %n instead of \n
        sb.append(String.format("%s Error%s occurred%n", serviceErrors.size(), serviceErrors.size() > 1 ? "s" : ""));
        for (ServiceErrorRestRep error : serviceErrors) {
            sb.append(String.format("Error %s: %s. %s%n",
                    error.getCode(), error.getCodeDescription(), error.getDetailedMessage()));
        }
        return sb.toString();
    }

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

    public List getServiceErrors() {
        return serviceErrors;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy