public static void Throw()

in src/DotPulsar/Internal/Extensions/CommandExtensions.cs [37:81]


    public static void Throw(this CommandSendError command)
        => Throw(command.Error, command.Message);

    public static void Throw(this CommandLookupTopicResponse command)
        => Throw(command.Error, command.Message);

    public static void Throw(this CommandError command)
        => Throw(command.Error, command.Message);

    public static void Throw(this CommandGetOrCreateSchemaResponse command)
        => Throw(command.ErrorCode, command.ErrorMessage);

    public static void Throw(this CommandPartitionedTopicMetadataResponse command)
        => Throw(command.Error, command.Message);

    private static void Throw(ServerError error, string message)
        => throw (error switch
        {
            ServerError.AuthenticationError => new AuthenticationException(message),
            ServerError.AuthorizationError => new AuthorizationException(message),
            ServerError.ChecksumError => new ChecksumException(message),
            ServerError.ConsumerAssignError => new ConsumerAssignException(message),
            ServerError.ConsumerBusy => new ConsumerBusyException(message),
            ServerError.ConsumerNotFound => new ConsumerNotFoundException(message),
            ServerError.IncompatibleSchema => new IncompatibleSchemaException(message),
            ServerError.InvalidTopicName => new InvalidTopicNameException(message),
            ServerError.InvalidTxnStatus => new InvalidTransactionStatusException(message),
            ServerError.MetadataError => new MetadataException(message),
            ServerError.NotAllowedError => new NotAllowedException(message),
            ServerError.PersistenceError => new PersistenceException(message),
            ServerError.ProducerBlockedQuotaExceededError => new ProducerBlockedQuotaExceededException($"{message}. Error code: {error}"),
            ServerError.ProducerBlockedQuotaExceededException => new ProducerBlockedQuotaExceededException($"{message}. Error code: {error}"),
            ServerError.ProducerBusy => new ProducerBusyException(message),
            ServerError.ProducerFenced => new ProducerFencedException(message),
            ServerError.ServiceNotReady => new ServiceNotReadyException(message),
            ServerError.SubscriptionNotFound => new SubscriptionNotFoundException(message),
            ServerError.TooManyRequests => new TooManyRequestsException(message),
            ServerError.TopicNotFound => new TopicNotFoundException(message),
            ServerError.TopicTerminatedError => new TopicTerminatedException(message),
            ServerError.TransactionConflict => new TransactionConflictException(message),
            ServerError.TransactionCoordinatorNotFound => new TransactionCoordinatorNotFoundException(message),
            ServerError.UnknownError => new UnknownException($"{message}. Error code: {error}"),
            ServerError.UnsupportedVersionError => new UnsupportedVersionException(message),
            _ => new UnknownException($"{message}. Error code: {error}")
        });