Module: CommandTower::Deserializers::Clients::Errors
- Defined in:
- app/deserializers/command_tower/deserializers/clients/errors.rb
Overview
Path composition for nested / indexed DeserializationError details.
Class Method Summary collapse
Class Method Details
.compose_path(current, segment) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/deserializers/command_tower/deserializers/clients/errors.rb', line 26 def compose_path(current, segment) current = current.to_s segment = segment.to_s return segment if current.empty? return current if segment.empty? if segment.start_with?("[") "#{segment}.#{current}" elsif current.start_with?("[") "#{segment}#{current}" else "#{segment}.#{current}" end end |
.prefix(error, segment) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/deserializers/command_tower/deserializers/clients/errors.rb', line 10 def prefix(error, segment) unless error.is_a?(::CommandTower::Clients::Errors::DeserializationError) raise ::CommandTower::Clients::Errors::ConfigurationError, "Errors.prefix expects CommandTower::Clients::Errors::DeserializationError" end details = error.details.is_a?(Hash) ? error.details.dup : {} details[:path] = compose_path(details[:path], segment) ::CommandTower::Clients::Errors::DeserializationError.new( message: error., details: details, cause: error.cause || error ) end |