Class HttpErrors
- java.lang.Object
-
- com.launchdarkly.sdk.internal.http.HttpErrors
-
public abstract class HttpErrors extends java.lang.Object
Contains shared helpers related to HTTP response validation.This class is for internal use only and should not be documented in the SDK API. It is not supported for any use outside of the LaunchDarkly SDKs, and is subject to change without notice.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HttpErrors.HttpErrorException
Represents an HTTP response error as an exception.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkIfErrorIsRecoverableAndLog(com.launchdarkly.logging.LDLogger logger, java.lang.String errorDesc, java.lang.String errorContext, int statusCode, java.lang.String recoverableMessage)
Logs an HTTP error or network error at the appropriate level and determines whether it is recoverable (as defined byisHttpErrorRecoverable(int)
).static java.lang.String
httpErrorDescription(int statusCode)
Returns a text description of an HTTP error.static boolean
isHttpErrorRecoverable(int statusCode)
Tests whether an HTTP error status represents a condition that might resolve on its own if we retry.
-
-
-
Method Detail
-
isHttpErrorRecoverable
public static boolean isHttpErrorRecoverable(int statusCode)
Tests whether an HTTP error status represents a condition that might resolve on its own if we retry.- Parameters:
statusCode
- the HTTP status- Returns:
- true if retrying makes sense; false if it should be considered a permanent failure
-
checkIfErrorIsRecoverableAndLog
public static boolean checkIfErrorIsRecoverableAndLog(com.launchdarkly.logging.LDLogger logger, java.lang.String errorDesc, java.lang.String errorContext, int statusCode, java.lang.String recoverableMessage)
Logs an HTTP error or network error at the appropriate level and determines whether it is recoverable (as defined byisHttpErrorRecoverable(int)
).- Parameters:
logger
- the logger to log toerrorDesc
- description of the errorerrorContext
- a phrase like "when doing such-and-such"statusCode
- HTTP status code, or 0 for a network errorrecoverableMessage
- a phrase like "will retry" to use if the error is recoverable- Returns:
- true if the error is recoverable
-
httpErrorDescription
public static java.lang.String httpErrorDescription(int statusCode)
Returns a text description of an HTTP error.- Parameters:
statusCode
- the status code- Returns:
- the error description
-
-