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

io.vrap.rmf.base.client.error.ExceptionFactory Maven / Gradle / Ivy

There is a newer version: 17.17.0
Show newest version

package io.vrap.rmf.base.client.error;

import io.vrap.rmf.base.client.ApiHttpException;
import io.vrap.rmf.base.client.ApiHttpRequest;
import io.vrap.rmf.base.client.ApiHttpResponse;
import io.vrap.rmf.base.client.ResponseSerializer;

/**
 * @deprecated use {@link HttpExceptionFactory} instead
 */
@Deprecated
public class ExceptionFactory {
    public static ApiHttpException create(final ApiHttpRequest request, final ApiHttpResponse response) {
        if (response.getStatusCode() >= 500) {
            return createServerException(request, response);
        }
        return createClientException(request, response);
    }

    public static ApiHttpException create(final ApiHttpRequest request, final ApiHttpResponse response,
            final ResponseSerializer serializer) {
        if (response.getStatusCode() >= 500) {
            return createServerException(request, response, serializer);
        }
        return createClientException(request, response, serializer);
    }

    public static ApiHttpException createServerException(final ApiHttpRequest request,
            final ApiHttpResponse response) {
        return createServerException(request, response, ResponseSerializer.of());
    }

    public static ApiHttpException createServerException(final ApiHttpRequest request,
            final ApiHttpResponse response, final ResponseSerializer serializer) {
        return HttpExceptionFactory.of(serializer).createServerException(request, response);
    }

    public static ApiHttpException createClientException(final ApiHttpRequest request,
            final ApiHttpResponse response) {
        return createClientException(request, response, ResponseSerializer.of());
    }

    public static ApiHttpException createClientException(ApiHttpRequest request, ApiHttpResponse response,
            final ResponseSerializer serializer) {
        return HttpExceptionFactory.of(serializer).createClientException(request, response);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy