Package org.biojava.nbio.core.util
Class HttpStatusException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
org.biojava.nbio.core.util.HttpStatusException
- All Implemented Interfaces:
Serializable
Signals that an HTTP request completed but returned a status code outside the
2xx range.
This exists so that callers can tell apart the two very different reasons a download can fail:
- The resource does not exist (
isNotFound(), i.e. HTTP 404 or 410). For a caller that tries several mirrors or several alternative data sources in turn, this simply means "not here, try the next one". - Anything else — a server error, a redirect that was not followed, an authentication failure. These usually mean the whole operation should be abandoned rather than silently treated as "no data available".
IOException, which is brittle.- Since:
- 7.3.0
- Author:
- Amr ALHOSSARY
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetUrl()booleanWhether the status indicates that the resource is simply not there, as opposed to a transport or server problem.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
HttpStatusException
- Parameters:
statusCode- the HTTP status code returned by the serverurl- the URL that was requestedresponseMessage- the HTTP reason phrase, may benull
-
-
Method Details
-
getStatusCode
public int getStatusCode()- Returns:
- the HTTP status code returned by the server
-
getUrl
- Returns:
- the URL that was requested
-
isNotFound
public boolean isNotFound()Whether the status indicates that the resource is simply not there, as opposed to a transport or server problem.- Returns:
truefor HTTP 404 (Not Found) and 410 (Gone)
-