Class: Norn::FailurePayload

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error, context = {}) ⇒ FailurePayload

Returns a new instance of FailurePayload.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/norn/errors.rb', line 19

def initialize(error, context = {})
  @error = case error
           when String
             Norn::Error.new(error)
           when Exception
             error
           else
             Norn::Error.new(error.to_s)
           end

  # 1. Early scan the error message to discover and cache keys in memory
  Norn::SecretScrubber.scrub(@error.message)

  # 2. Sanitize context with all cached keys loaded
  @context = sanitize_context(context || {})
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



17
18
19
# File 'lib/norn/errors.rb', line 17

def context
  @context
end

#errorObject (readonly)

Returns the value of attribute error.



17
18
19
# File 'lib/norn/errors.rb', line 17

def error
  @error
end

Instance Method Details

#backtraceObject



44
45
46
# File 'lib/norn/errors.rb', line 44

def backtrace
  @error.backtrace
end

#messageObject



40
41
42
# File 'lib/norn/errors.rb', line 40

def message
  scrub(@error.message)
end

#with_context(additional_context) ⇒ Object



36
37
38
# File 'lib/norn/errors.rb', line 36

def with_context(additional_context)
  self.class.new(@error, @context.merge(additional_context || {}))
end