10Duke Scale SDK for Java
Loading...
Searching...
No Matches
tenduke.scale.api.exception.ExceptionBuilder Class Reference

Detailed Description

Base class for providing an easy to read and handle exception creation.

Utilizes the following exceptions with the correct error codes during creation

Static Public Member Functions

static ApiException createApiException (final int statusCode, final String message)
 Builder for API exceptions that are missing error code.
 
static ApiException createApiException (final int statusCode, final String errorCode, final String message, final Throwable cause)
 Create a new API exception with detail given by arguments.
 
static ApiException createApiException (final int statusCode, final String errorCode, final String message, final Throwable cause, final ErrorResponseBody responseBody)
 Create a new API exception with detail given by arguments.Outcome is the same as calling the equivalent constructor for ApiException.
 
static SdkException internalError (final String message)
 Creates a new SdkException with errorCode set to SDK_INTERNAL_ERROR_CODE.
 
static SdkException internalError (final String message, final Throwable cause)
 Creates a new SdkException with errorCode set to SDK_INTERNAL_ERROR_CODE.
 
static SdkException internalTimeoutError (final String message)
 Creates a new SdkException with errorCode set to SDK_TIMEOUT_ERROR_CODE.
 
static SdkException internalTimeoutError (final String message, final Throwable cause)
 Creates a new SdkException with errorCode set to SDK_TIMEOUT_ERROR_CODE.
 
static ApiException badRequest (final Throwable cause)
 Tells the client that the request is not valid.
 
static ApiException badRequest (final String message)
 Tells the client that the request is not valid.
 
static ApiException badRequest (final String message, final Throwable cause)
 Tells the client that the request is not valid generally.
 
static ApiException forbidden (final String message)
 Tells the client that the server refuses to authorize the request.
 
static ApiException conflict (final Throwable cause)
 Tells the client that the service state does not allow the requested data access.
 
static ApiException conflict (final String message)
 Tells the client that the service state does not allow the requested data access.
 
static ApiException conflict (final String message, final Throwable cause)
 Tells the client that the service state does not allow the requested data access.
 
static ApiException internalServerError (final String message)
 Tells the client that the server encountered an unexpected issue while fulfilling the request.
 
static ApiException internalServerError (final String message, final Throwable cause)
 Tells the client that the server encountered an unexpected issue while fulfilling the request.
 
static ApiException notFound (final String message)
 Tells the client that the requested resource does not exist.
 
static ApiException tooManyRequests ()
 Tells the client that it has made too many requests and the request rate should be reduced.
 
static ApiException tooManyRequests (final String message)
 Tells the client that it has made too many requests and the request rate should be reduced.
 
static ApiException unauthorized ()
 Tell client to authenticate.
 
static TokenException invalidJwtToken ()
 Tells that JWT token is invalid.
 
static TokenException invalidJwtToken (final String message, final Throwable cause)
 Tells that JWT token is invalid.
 
static TokenException invalidJwtHeader ()
 Tells that JWT token contains an invalid header.
 
static TokenException invalidJwtHeader (final String message, final Throwable cause)
 Tells that JWT token contains an invalid header.
 
static TokenException invalidJwtPayload ()
 Tells that JWT token contains an invalid payload.
 
static TokenException invalidJwtSignature ()
 Tells that JWT token contains an invalid signature.
 
static TokenException notActiveJwtToken ()
 Tells that JWT token is not active.
 
static TokenException invalidJwtAlgorithm ()
 Tells that JWT token algorithm is not valid.
 
static TokenException invalidJwtAudience ()
 Tells that JWT token audience is not valid.
 
static TokenException invalidJwtIssuer ()
 Tells that JWT token issuer is not valid.
 
static TokenException invalidJwtIssuedAt ()
 Tells that JWT token issued at is not valid.
 
static TokenException invalidJwtId ()
 Tells that JWT token JWT id is not valid.
 
static TokenException missingRequiredJwtClaim ()
 Tells that JWT token is missing a required claim.
 
static TokenException missingRequiredJwtClaim (final String message, final Throwable cause)
 Tells that JWT token is missing a required claim.
 
static TokenException missingJwtSigningKey ()
 Tells that JWT signing key is null or empty.
 
static TokenException missingJwtSigningKey (final String message, final Throwable cause)
 Tells that JWT signing key is null or empty.
 
static TokenException missingJwtVerificationKey ()
 Tells that JWT verification key is null or empty.
 
static TokenException missingJwtVerificationKey (final String message, final Throwable cause)
 Tells that JWT verification key is null or empty.
 
static ConfigException missingConfig (final String message)
 Tells that configuration is missing.
 
static ConfigException invalidConfig (final String message)
 Tells that configuration is invalid.
 

Static Public Attributes

static final int DEFAULT_API_STATUS
 
static final String DEFAULT_API_ERROR_CODE
 
static final String SDK_INTERNAL_ERROR_CODE = "internal_error"
 
static final String SDK_TIMEOUT_ERROR_CODE = "timeout_error"
 

Member Function Documentation

◆ badRequest() [1/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.badRequest ( final String message)
static

Tells the client that the request is not valid.

The request must not be repeated as such as it will reproduce the same outcome.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ badRequest() [2/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.badRequest ( final String message,
final Throwable cause )
static

Tells the client that the request is not valid generally.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
ApiException.

◆ badRequest() [3/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.badRequest ( final Throwable cause)
static

Tells the client that the request is not valid.

The request must not be repeated as such as it will reproduce the same outcome.

Parameters
causenested cause.
Returns
ApiException.

◆ conflict() [1/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.conflict ( final String message)
static

Tells the client that the service state does not allow the requested data access.

This can be for example due to an unique key constraint failure.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ conflict() [2/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.conflict ( final String message,
final Throwable cause )
static

Tells the client that the service state does not allow the requested data access.

This can be for example due to an unique key constraint failure.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
ApiException.

◆ conflict() [3/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.conflict ( final Throwable cause)
static

Tells the client that the service state does not allow the requested data access.

This can be for example due to an unique key constraint failure.

Parameters
causenested cause.
Returns
ApiException.

◆ createApiException() [1/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.createApiException ( final int statusCode,
final String errorCode,
final String message,
final Throwable cause )
static

Create a new API exception with detail given by arguments.

Outcome is the same as calling the equivalent constructor for ApiException.

Parameters
statusCodestatus code from HTTP response.
errorCodebrief message of the error.
messagedetailed message of the error.
causenested cause.
Returns
ApiException.

◆ createApiException() [2/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.createApiException ( final int statusCode,
final String errorCode,
final String message,
final Throwable cause,
final ErrorResponseBody responseBody )
static

Create a new API exception with detail given by arguments.Outcome is the same as calling the equivalent constructor for ApiException.

Parameters
statusCodestatus code from HTTP response.
errorCodebrief message of the error.
messagedetailed message of the error.
causenested cause.
responseBodybody of the error response.
Returns
ApiException.

◆ createApiException() [3/3]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.createApiException ( final int statusCode,
final String message )
static

Builder for API exceptions that are missing error code.

Maps the statusCode to a HttpResponseStatus.Status reason phrase or sets the error code to HttpResponseStatus.Status.INTERNAL_SERVER_ERROR.getReasonPhrase() if the mapping fails.

Parameters
statusCodestatus code from HTTP response.
messagedetailed message of the error.
Returns
ApiException.

◆ forbidden()

static ApiException tenduke.scale.api.exception.ExceptionBuilder.forbidden ( final String message)
static

Tells the client that the server refuses to authorize the request.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ internalError() [1/2]

static SdkException tenduke.scale.api.exception.ExceptionBuilder.internalError ( final String message)
static

Creates a new SdkException with errorCode set to SDK_INTERNAL_ERROR_CODE.

Passes the value of the message argument to the JDK exception base class.

Parameters
messagedetailed message of the error.
Returns
tenduke.sdk.core.exception.TokenException.

◆ internalError() [2/2]

static SdkException tenduke.scale.api.exception.ExceptionBuilder.internalError ( final String message,
final Throwable cause )
static

Creates a new SdkException with errorCode set to SDK_INTERNAL_ERROR_CODE.

Passes the values of the message argument and throwable cause to the JDK exception base class.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException.

◆ internalServerError() [1/2]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.internalServerError ( final String message)
static

Tells the client that the server encountered an unexpected issue while fulfilling the request.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ internalServerError() [2/2]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.internalServerError ( final String message,
final Throwable cause )
static

Tells the client that the server encountered an unexpected issue while fulfilling the request.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
ApiException.

◆ internalTimeoutError() [1/2]

static SdkException tenduke.scale.api.exception.ExceptionBuilder.internalTimeoutError ( final String message)
static

Creates a new SdkException with errorCode set to SDK_TIMEOUT_ERROR_CODE.

Passes the value of the message argument to the JDK exception base class.

Parameters
messagedetailed message of the error.
Returns
tenduke.sdk.core.exception.TokenException.

◆ internalTimeoutError() [2/2]

static SdkException tenduke.scale.api.exception.ExceptionBuilder.internalTimeoutError ( final String message,
final Throwable cause )
static

Creates a new SdkException with errorCode set to SDK_TIMEOUT_ERROR_CODE.

Passes the values of the message argument and throwable cause to the JDK exception base class.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException.

◆ invalidConfig()

static ConfigException tenduke.scale.api.exception.ExceptionBuilder.invalidConfig ( final String message)
static

Tells that configuration is invalid.

Parameters
messagedetailed message of the error.
Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtAlgorithm()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtAlgorithm ( )
static

Tells that JWT token algorithm is not valid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtAudience()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtAudience ( )
static

Tells that JWT token audience is not valid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtHeader() [1/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtHeader ( )
static

Tells that JWT token contains an invalid header.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtHeader() [2/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtHeader ( final String message,
final Throwable cause )
static

Tells that JWT token contains an invalid header.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtId()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtId ( )
static

Tells that JWT token JWT id is not valid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtIssuedAt()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtIssuedAt ( )
static

Tells that JWT token issued at is not valid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtIssuer()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtIssuer ( )
static

Tells that JWT token issuer is not valid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtPayload()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtPayload ( )
static

Tells that JWT token contains an invalid payload.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtSignature()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtSignature ( )
static

Tells that JWT token contains an invalid signature.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtToken() [1/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtToken ( )
static

Tells that JWT token is invalid.

Returns
tenduke.sdk.core.exception.TokenException

◆ invalidJwtToken() [2/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.invalidJwtToken ( final String message,
final Throwable cause )
static

Tells that JWT token is invalid.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException

◆ missingConfig()

static ConfigException tenduke.scale.api.exception.ExceptionBuilder.missingConfig ( final String message)
static

Tells that configuration is missing.

Parameters
messagedetailed message of the error.
Returns
tenduke.sdk.core.exception.TokenException

◆ missingJwtSigningKey() [1/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingJwtSigningKey ( )
static

Tells that JWT signing key is null or empty.

Returns
tenduke.sdk.core.exception.TokenException

◆ missingJwtSigningKey() [2/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingJwtSigningKey ( final String message,
final Throwable cause )
static

Tells that JWT signing key is null or empty.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException

◆ missingJwtVerificationKey() [1/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingJwtVerificationKey ( )
static

Tells that JWT verification key is null or empty.

Returns
tenduke.sdk.core.exception.TokenException

◆ missingJwtVerificationKey() [2/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingJwtVerificationKey ( final String message,
final Throwable cause )
static

Tells that JWT verification key is null or empty.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException

◆ missingRequiredJwtClaim() [1/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingRequiredJwtClaim ( )
static

Tells that JWT token is missing a required claim.

Returns
tenduke.sdk.core.exception.TokenException

◆ missingRequiredJwtClaim() [2/2]

static TokenException tenduke.scale.api.exception.ExceptionBuilder.missingRequiredJwtClaim ( final String message,
final Throwable cause )
static

Tells that JWT token is missing a required claim.

Parameters
messagedetailed message of the error.
causenested cause.
Returns
tenduke.sdk.core.exception.TokenException

◆ notActiveJwtToken()

static TokenException tenduke.scale.api.exception.ExceptionBuilder.notActiveJwtToken ( )
static

Tells that JWT token is not active.

Returns
tenduke.sdk.core.exception.TokenException

◆ notFound()

static ApiException tenduke.scale.api.exception.ExceptionBuilder.notFound ( final String message)
static

Tells the client that the requested resource does not exist.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ tooManyRequests() [1/2]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.tooManyRequests ( )
static

Tells the client that it has made too many requests and the request rate should be reduced.

Returns
ApiException.

◆ tooManyRequests() [2/2]

static ApiException tenduke.scale.api.exception.ExceptionBuilder.tooManyRequests ( final String message)
static

Tells the client that it has made too many requests and the request rate should be reduced.

Parameters
messagedetailed message of the error.
Returns
ApiException.

◆ unauthorized()

static ApiException tenduke.scale.api.exception.ExceptionBuilder.unauthorized ( )
static

Tell client to authenticate.

Must also include WWW-Authenticate header that describes how to authenticate.

Returns
ApiException.

Member Data Documentation

◆ DEFAULT_API_ERROR_CODE

final String tenduke.scale.api.exception.ExceptionBuilder.DEFAULT_API_ERROR_CODE
static
Initial value:
= HttpResponseStatus
.Status.INTERNAL_SERVER_ERROR
.getReasonPhrase()

◆ DEFAULT_API_STATUS

final int tenduke.scale.api.exception.ExceptionBuilder.DEFAULT_API_STATUS
static
Initial value:
= HttpResponseStatus
.Status.INTERNAL_SERVER_ERROR
.getStatusCode()

◆ SDK_INTERNAL_ERROR_CODE

final String tenduke.scale.api.exception.ExceptionBuilder.SDK_INTERNAL_ERROR_CODE = "internal_error"
static

◆ SDK_TIMEOUT_ERROR_CODE

final String tenduke.scale.api.exception.ExceptionBuilder.SDK_TIMEOUT_ERROR_CODE = "timeout_error"
static

The documentation for this class was generated from the following file: