Exception: Rabbit::Receiving::MalformedMessage

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rabbit/receiving/malformed_message.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_model, errors) ⇒ MalformedMessage

Returns a new instance of MalformedMessage.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rabbit/receiving/malformed_message.rb', line 17

def initialize(message_model, errors)
  self.message_model = message_model
  self.errors = Array(errors)

  errors_list = Array(errors).map { |e| "  - #{e}" }.join("\n")

  super(<<~MESSAGE)
    Malformed message rejected for following reasons:
    #{errors_list}
    Message: #{message_model.attributes.inspect}
  MESSAGE
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



5
6
7
# File 'lib/rabbit/receiving/malformed_message.rb', line 5

def errors
  @errors
end

#message_modelObject

Returns the value of attribute message_model.



5
6
7
# File 'lib/rabbit/receiving/malformed_message.rb', line 5

def message_model
  @message_model
end

Class Method Details

.loggerObject



7
8
9
# File 'lib/rabbit/receiving/malformed_message.rb', line 7

def self.logger
  @logger ||= Rabbit.config.malformed_logger
end

.raise!(message_model, errors, backtrace = caller(1)) ⇒ Object

Raises:

  • (error)


11
12
13
14
15
# File 'lib/rabbit/receiving/malformed_message.rb', line 11

def self.raise!(message_model, errors, backtrace = caller(1))
  error = new(message_model, errors)
  logger.error error.message
  raise error, error.message, backtrace
end