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

dev.fitko.fitconnect.api.exceptions.internal.RestApiException Maven / Gradle / Ivy

Go to download

Library that provides client access to the FIT-Connect api-endpoints for sending, subscribing and routing

There is a newer version: 2.3.5
Show newest version
package dev.fitko.fitconnect.api.exceptions.internal;

public class RestApiException extends RuntimeException {

    private int statusCode = 500;

    public RestApiException(final String errorMessage, final Throwable error) {
        super(errorMessage, error);
    }

    public RestApiException(final String errorMessage, final Throwable error, final int statusCode) {
        super(errorMessage, error);
        this.statusCode = statusCode;
    }

    public RestApiException(final String errorMessage) {
        super(errorMessage);
    }

    public RestApiException(final String errorMessage, int statusCode) {
        super(errorMessage);
        this.statusCode = statusCode;
    }

    public RestApiException fromRootCause(Throwable throwable){
        return new RestApiException(throwable.getMessage(), throwable, this.statusCode);
    }

    public int getStatusCode() {
        return statusCode;
    }

    public boolean isNotFound() {
        return this.statusCode == 404;
    }

    public boolean isStatusCodeSuccessful() {
        return statusCode >= 200 && statusCode <= 226;
    }

    public boolean isClientError() {
        return statusCode >= 400 && statusCode < 500;
    }

    public boolean isServerError() {
        return statusCode >= 500;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy