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

io.sphere.sdk.client.SphereServiceException Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.client;

import com.fasterxml.jackson.databind.JsonNode;
import io.sphere.sdk.json.SphereJsonUtils;
import io.sphere.sdk.models.SphereException;

import javax.annotation.Nullable;
import java.util.Optional;

/**
 *
 * Exception thrown when SPHERE.IO responds
with a status code other than HTTP 2xx.
* */ public abstract class SphereServiceException extends SphereException { static final long serialVersionUID = 0L; private final Integer statusCode; public SphereServiceException(final Integer statusCode) { this.statusCode = statusCode; } public SphereServiceException(final String message, final Integer statusCode) { super(message); this.statusCode = statusCode; } public SphereServiceException(final Throwable cause, final Integer statusCode) { super(cause); this.statusCode = statusCode; } public SphereServiceException(final String message, final Throwable cause, final Integer statusCode) { super(message, cause); this.statusCode = statusCode; } public Integer getStatusCode() { return statusCode; } @Nullable public final JsonNode getJsonBody() { return Optional.ofNullable(httpResponse) .map(r -> r.getResponseBody()) .map(body -> SphereJsonUtils.parse(body)) .orElse(null); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy