Class Tm1ApiException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
io.skipcheck.tm1.client.error.Tm1Exception
io.skipcheck.tm1.client.error.Tm1ApiException
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
Tm1AuthenticationException, Tm1BadRequestException, Tm1ConflictException, Tm1ForbiddenException, Tm1NotFoundException, Tm1NotImplementedException, Tm1PreconditionFailedException, Tm1ServerException
public sealed class Tm1ApiException
extends Tm1Exception
permits Tm1BadRequestException, Tm1AuthenticationException, Tm1ForbiddenException, Tm1NotFoundException, Tm1ConflictException, Tm1PreconditionFailedException, Tm1NotImplementedException, Tm1ServerException
TM1 answered with an error status. Carries the status, the parsed OData error and what
it means (
kind()). The subclass follows from the kind first and the status
second, so a "not found" TM1 reports as a 400 is still a Tm1NotFoundException.- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTm1ApiException(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url) Creates an exception for an error response. -
Method Summary
Modifier and TypeMethodDescription@Nullable ODataErrorerror()The OData error body, ornullif the response didn't have one.booleanTrue for statuses where trying again later may work: 429, 502, 503 and 504.kind()What the error means.booleanFalse for client errors (4xx), which TM1 rejected; true for server errors, except 501.static Tm1ApiExceptionof(int status, @Nullable ODataError error, String method, String url, Tm1ErrorClassifier classifier) The exception for an error response, classified withclassifier.static Tm1ApiExceptionof(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url) The exception for an error response whose kind is already known.intstatus()The HTTP status.Methods inherited from class Tm1Exception
method, urlMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
Tm1ApiException
protected Tm1ApiException(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url) Creates an exception for an error response.- Parameters:
status- the HTTP statuskind- what the error meanserror- the parsed error body, ornullmethod- the request's HTTP methodurl- the request's URL, without credentials
-
-
Method Details
-
of
public static Tm1ApiException of(int status, @Nullable ODataError error, String method, String url, Tm1ErrorClassifier classifier) The exception for an error response, classified withclassifier.- Parameters:
status- the HTTP statuserror- the parsed error body, ornullif the body wasn't an OData errormethod- the request's HTTP methodurl- the request's URL, without credentialsclassifier- works out the error's kind from the status and body- Returns:
- the subclass matching the kind and status
-
of
public static Tm1ApiException of(int status, Tm1ErrorKind kind, @Nullable ODataError error, String method, String url) The exception for an error response whose kind is already known.- Parameters:
status- the HTTP statuskind- what the error meanserror- the parsed error body, ornullif the body wasn't an OData errormethod- the request's HTTP methodurl- the request's URL, without credentials- Returns:
- the subclass matching the kind first and the status second
-
isRetryable
public boolean isRetryable()True for statuses where trying again later may work: 429, 502, 503 and 504.- Specified by:
isRetryablein classTm1Exception- Returns:
trueif a retry could succeed
-
mayHaveApplied
public boolean mayHaveApplied()False for client errors (4xx), which TM1 rejected; true for server errors, except 501.- Specified by:
mayHaveAppliedin classTm1Exception- Returns:
falseonly if TM1 certainly didn't act on the request
-
status
public int status()The HTTP status.- Returns:
- the status code, such as
404
-
kind
-
error
The OData error body, ornullif the response didn't have one.- Returns:
- the error, or
null
-