Class: Remap::Failure

Inherits:
Dry::Concrete
  • Object
show all
Defined in:
lib/remap/failure.rb,
lib/remap/failure/error.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Instance Method Details

#exception(backtrace) ⇒ Failure::Error

Parameters:

  • backtrace (Array<String>)

    Backtrace from Kernel.caller

Returns:



33
34
35
36
37
# File 'lib/remap/failure.rb', line 33

def exception(backtrace)
  e = Error.new(failure: self)
  e.set_backtrace(backtrace)
  e
end

#merge(other) ⇒ Failure

Merges two failures and returns a new failure

Parameters:

Returns:



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/remap/failure.rb', line 13

def merge(other)
  unless other.is_a?(self.class)
    raise ArgumentError, "Cannot merge %s (%s) with %s (%s)" % [
      self, self.class, other, other.class
    ]
  end

  failure = attributes.merge(other.attributes) do |key, value1, value2|
    case [key, value1, value2]
    in [:failures | :notices, Array, Array]
      value1 + value2
    end
  end

  new(failure)
end