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

mesosphere.client.common.HttpResponseException Maven / Gradle / Ivy

There is a newer version: 0.6.3
Show newest version
package mesosphere.client.common;

import com.google.common.base.MoreObjects;

public abstract class HttpResponseException extends RuntimeException {
    private int status;
    private String message;
    private final String methodKey;
    private final String details;

    protected HttpResponseException(int status, String message, String methodKey, String details) {
        this.status = status;
        this.message = message;
        this.methodKey = methodKey;
        this.details = details;
    }

    protected HttpResponseException(int status, String message) {
        this.status = status;
        this.message = message;
        details = null;
        methodKey = null;
    }

    /**
     * Gets the HTTP status code of the failure, such as 404.
     * @return status code of the HTTP response.
     */
    public int getStatus() {
        return status;
    }

    @Override
    public String getMessage() {
        return message + " (http status: " + status + ")";
    }

    @Override
    public String toString() {
        return MoreObjects.toStringHelper(this)
                .add("Message", message)
                .add("Status", status)
                .add("Details", details)
                .omitNullValues().toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy