Class: Pulsar::Internal::BrokerErrorMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/pulsar/internal/broker_error_mapper.rb

Overview

Converts broker protocol error codes into typed client exceptions.

Constant Summary collapse

ERROR_CLASSES =
{
  AuthenticationError: AuthenticationError,
  AuthorizationError: AuthorizationError,
  TopicNotFound: TopicNotFoundError,
  ProducerBusy: ProducerBusyError,
  ProducerFenced: ProducerBusyError,
  ConsumerBusy: ConsumerBusyError
}.freeze

Class Method Summary collapse

Class Method Details

.from(server_error, message) ⇒ Object



16
17
18
19
20
# File 'lib/pulsar/internal/broker_error_mapper.rb', line 16

def self.from(server_error, message)
  error_class = ERROR_CLASSES.fetch(server_error, BrokerError)
  text = error_class == BrokerError ? "#{server_error}: #{message}" : message
  error_class.new(text)
end