Final Class Yiisoft\Request\Body\BadRequestHandler
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Default handler that is used when there is an error during parsing a request.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| handle() | Yiisoft\ |
|
| withParserException() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $responseFactory | \ |
|
public function __construct(
private readonly ResponseFactoryInterface $responseFactory,
) {}
| public \ | ||
| $request | \ |
|
public function handle(ServerRequestInterface $request): ResponseInterface
{
$response = $this->responseFactory->createResponse(Status::BAD_REQUEST);
$response
->getBody()
->write(Status::TEXTS[Status::BAD_REQUEST]);
if ($this->parserException !== null) {
$response
->getBody()
->write("\n" . $this->parserException->getMessage());
}
return $response;
}
| public Yiisoft\ | ||
| $e | Yiisoft\ |
|
public function withParserException(ParserException $e): BadRequestHandlerInterface
{
$new = clone $this;
$new->parserException = $e;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.