private static function handleError(int $status, string $message = null)
    {
        if ($status === 400) {
            throw new BadRequestException($message, $status);
        }

        if ($status === 422) {
            throw new ValidationFailedException($message, $status);
        }

        if ($status === 429) {
            throw new ApiLimitExceededException($message, $status);
        }

        if ($status < 500) {
            throw new ClientErrorException($message, $status);
        }

        throw new ServerErrorException($message, $status);
    }