Class PushError
java.lang.Object
java.lang.Throwable
java.lang.Exception
com.iizix.server.push.engine.http.PushError
- All Implemented Interfaces:
Serializable
A refused request: the HTTP status, the
error code from the closed vocabulary of PushWire.ERRORS and the human message, plus any extra members the reply carries (a 409 carries vapid_reason and fcm_reason).Every failure the handler answers is one of these, so the reply shape of PUSH-WIRE-CONTRACT.md section 1.2 is built in one place, toJSON().
- Author:
- Christopher Mindus
- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionfinal StringTheerrorcode, one ofPushWire.ERRORS.final longThe seconds of theRetry-Afterheader the reply carries, zero for none: onlytooManyAttempts(long)sets it.final intThe HTTP status.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionstatic PushErrorbadRequest(String message) A 400bad_request.static PushErrorA 403forbidden.toJSON()Builds the reply body:{ok:false, error, message}plus the extra members.static PushErrortooManyAttempts(long retryAfterSeconds) A 429 for a request whose source is held back after too many failed attempts: the per-source throttle of the server's sign-in (order 638, CC-FIX-PUSH-API-SIGNIN).static PushErrorunauthenticated(String message) A 401unauthenticated.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
Field Details
status
public final int statusThe HTTP status.code
Theerrorcode, one ofPushWire.ERRORS.retryAfter
public final long retryAfterThe seconds of theRetry-Afterheader the reply carries, zero for none: onlytooManyAttempts(long)sets it.
Constructor Details
PushError
Constructor.- Parameters:
status- The HTTP status.code- The error code, one ofPushWire.ERRORS.message- The human text, English, never localized, never a stack trace.
PushError
Constructor with extra reply members.- Parameters:
status- The HTTP status.code- The error code, one ofPushWire.ERRORS.message- The human text.extra- Extra members of the reply, null for none.
Method Details
badRequest
unauthenticated
forbidden
tooManyAttempts
A 429 for a request whose source is held back after too many failed attempts: the per-source throttle of the server's sign-in (order 638, CC-FIX-PUSH-API-SIGNIN). Theerrorisunauthenticated- the caller is not authenticated, and the closed vocabulary ofPushWire.ERRORSis not widened - and the reply carriesRetry-After. It tells the caller nothing about any account: the same answer whatever the user name and the password.- Parameters:
retryAfterSeconds- The seconds until the source may attempt again; at least 1 is sent.- Returns:
- The error.
toJSON
Builds the reply body:{ok:false, error, message}plus the extra members.- Returns:
- A new JSON object.