private function rowLimiter(int $limit = 1000): Closure
    {
        return static function () use ($limit): void {
            static $n = 0;

            if (++$n > $limit) {
                $message = I18N::translate('The search returned too many results.');

                throw new InternalServerErrorException($message);
            }
        };
    }