Module: Foobara::CommandPatternImplementation::Concerns::Errors::ClassMethods

Defined in:
foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/errors.rb

Instance Method Summary collapse

Instance Method Details

#lookup_error_class(key) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/errors.rb', line 34

def lookup_error_class(key)
  key = ErrorKey.to_s_type(key)

  unless error_context_type_map.key?(key)
    # :nocov:
    raise "No error class was registered for #{key}"
    # :nocov:
  end

  error_context_type_map[key].error_class
end

#lookup_input_error_class(symbol, path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/errors.rb', line 8

def lookup_input_error_class(symbol, path)
  key = ErrorKey.new(symbol:, path:, category: :data)
  key = key.to_s_type

  unless error_context_type_map.key?(key)
    # :nocov:
    raise "No error class was registered for #{key}"
    # :nocov:
  end

  error_context_type_map[key].error_class
end

#lookup_runtime_error_class(symbol) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'foobara-0.0.110/projects/command/src/command_pattern_implementation/concerns/errors.rb', line 21

def lookup_runtime_error_class(symbol)
  key = ErrorKey.new(symbol:, category: :runtime)
  key = key.to_s_type

  unless error_context_type_map.key?(key)
    # :nocov:
    raise "No error class was registered for #{key}"
    # :nocov:
  end

  error_context_type_map[key].error_class
end