class HTTPResponse_Exception extends Exception (View source)

A HTTPResponse encapsulated in an exception, which can interrupt the processing flow and be caught by the RequestHandler and returned to the user.

Example Usage:

throw new HTTPResponse_Exception('This request was invalid.', 400);
throw new HTTPResponse_Exception(new HTTPResponse('There was an internal server error.', 500));

Properties

protected HTTPResponse $response

Methods

public
__construct(HTTPResponse|string $body = null, int $statusCode = null, string $statusDescription = null)

No description

public
getResponse()

No description

public
setResponse(HTTPResponse $response)

No description

Details

__construct(HTTPResponse|string $body = null, int $statusCode = null, string $statusDescription = null)

No description

Parameters

HTTPResponse|string $body

Either the plaintext content of the error message, or an HTTPResponse object representing it. In either case, the $statusCode and $statusDescription will be the HTTP status of the resulting response.

int $statusCode
string $statusDescription

See also

HTTPResponse::__construct

HTTPResponse getResponse()

No description

Return Value

HTTPResponse

setResponse(HTTPResponse $response)

No description

Parameters

HTTPResponse $response