class Builder

Class responsible for building meaningful exceptions. For HTTP problems, it produces a {see HttpError} exception, and supplies a error message with reasonable defaults. For user input problems, it produces a {see UserInputError} exception. For both, the problem is described, a potential solution is offered and a link to further information is included.

Methods

__construct (ClientInterface $client = null)

No description

str (MessageInterface $message) : string

No description

httpError (RequestInterface $request, ResponseInterface $response) : BadResponseError

Helper method responsible for constructing and returning {see BadResponseError} exceptions.

userInputError (string $expectedType, mixed $userValue, string $furtherLink = null) : UserInputError

Helper method responsible for constructing and returning {see UserInputError} exceptions.

Details

__construct(ClientInterface $client = null)

Parameters

$client ClientInterface

Example code

$builder->__construct($client);

str(MessageInterface $message)

Parameters

$message MessageInterface

Return value

string

Example code

$string = $builder->str($message);

httpError(RequestInterface $request, ResponseInterface $response)

Helper method responsible for constructing and returning {see BadResponseError} exceptions.

Parameters

$request RequestInterface The faulty request
$response ResponseInterface The error-filled response

Return value

BadResponseError

Example code

$badResponseError = $builder->httpError($request, $response);

userInputError(string $expectedType, mixed $userValue, string $furtherLink = null)

Helper method responsible for constructing and returning {see UserInputError} exceptions.

Parameters

$expectedType string The type that was expected from the user
$userValue mixed The incorrect value the user actually provided
$furtherLink string A link to further information if necessary (optional).

Return value

UserInputError

Example code

$userInputError = $builder->userInputError($expectedType, $userValue, $furtherLink);