Exception: Confium::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/confium/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, details_hash = nil, details: {}) ⇒ Error

The native extension constructs errors positionally (message, details_hash) — the same shape every typed subclass accepts via Errors::Coerce. Accepting it here keeps the whole family uniform; the keyword form still works.



19
20
21
22
23
24
25
26
27
# File 'lib/confium/errors.rb', line 19

def initialize(message = nil, details_hash = nil, details: {})
  base = if details_hash.is_a?(Hash) && !details_hash.empty?
           details_hash
         else
           details
         end
  @details = base.transform_keys(&:to_sym)
  super(message)
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



13
14
15
# File 'lib/confium/errors.rb', line 13

def details
  @details
end

Instance Method Details

#to_hObject



29
30
31
# File 'lib/confium/errors.rb', line 29

def to_h
  { class: self.class.name, message: message, details: details }
end