io.castle.client.internal.utils.OkHttpExceptionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of castle-java Show documentation
Show all versions of castle-java Show documentation
Castle adds real-time monitoring of your authentication stack, instantly notifying you and your users
on potential account hijacks.
package io.castle.client.internal.utils;
import io.castle.client.model.CastleApiInternalServerErrorException;
import io.castle.client.model.CastleApiTimeoutException;
import io.castle.client.model.CastleRuntimeException;
import io.castle.client.model.CastleServerErrorException;
import okhttp3.Response;
import java.io.IOException;
import java.net.SocketTimeoutException;
public class OkHttpExceptionUtil {
public static CastleRuntimeException handle(IOException e) {
if (e instanceof SocketTimeoutException) {
return new CastleApiTimeoutException(e);
}
return new CastleRuntimeException(e);
}
public static void handle(Response response) throws CastleServerErrorException {
if (!response.isSuccessful() && !response.isRedirect()) {
if (response.code() == 500) {
throw new CastleApiInternalServerErrorException(response);
}
throw new CastleServerErrorException(response);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy