public function processNextEvent(callable $handler): void
    {
        /** @var Context $context */
        [$event, $context] = $this->waitNextInvocation();

        try {
            $this->sendResponse($context->getAwsRequestId(), $handler($event, $context));
        } catch (\Throwable $e) {
            $this->signalFailure($context->getAwsRequestId(), $e);
        }
    }