Skip to content

CarpServiceRequestException

Exception for CAWS REST/HTTP service communication.

Thrown for non-success HTTP responses with a decodable JSON body, including CAWS application exceptions. The latter typically arise from CARP Core exceptions on the server side, which are mapped to HTTP status codes and messages sent back to the client. Transport failures and undecodable response bodies can propagate as other exceptions.

Inheritance
Implementers

Constructors

CarpServiceRequestException.fromHttpStatus

CarpServiceRequestException.fromHttpStatus(
  1. int httpStatusCode,
  2. dynamic response
)

Creates the matching exception from an HTTP httpStatusCode and the decoded JSON response body.

Returns a CarpBadRequestException, CarpUnauthorizedException, CarpNotFoundException or CarpInternalServerException for the matching status codes, and a plain CarpServiceRequestException otherwise.

There are two types of error messages - from CAWS and from NGINX. CAWS errors contain 'path' and 'exception' fields, whereas NGINX errors contain an 'instance' field.

CarpServiceRequestException

CarpServiceRequestException(
  1. String message, {
  2. required HTTPStatus httpStatus,
  3. String? exception,
  4. String? path,
})

Properties

exception

String? exception
getter/setter pair

The Java exception from CARP Core.

httpStatus

HTTPStatus httpStatus
getter/setter pair

The HTTP status from CAWS associated with this exception.

path

String? path
getter/setter pair

The URL path that caused the exception.

Methods

toString

String toString()
override

A string representation of this object.

Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.

Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.