private function sendErrorResponse(ClientException $exception): \Generator
    {
        $message = $exception->getMessage();
        $status = $exception->getCode() ?: Status::BAD_REQUEST;

        /** @var \Amp\Http\Server\Response $response */
        $response = yield $this->errorHandler->handleError($status, $message);

        $response->setHeader("connection", "close");

        yield from $this->send($response);
    }