Class: RubyReactor::Failure
- Inherits:
-
Object
- Object
- RubyReactor::Failure
- Defined in:
- lib/ruby_reactor.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
readonly
Returns the value of attribute backtrace.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#inputs ⇒ Object
readonly
Returns the value of attribute inputs.
-
#reactor_name ⇒ Object
readonly
Returns the value of attribute reactor_name.
-
#retryable ⇒ Object
readonly
Returns the value of attribute retryable.
-
#step_arguments ⇒ Object
readonly
Returns the value of attribute step_arguments.
-
#step_name ⇒ Object
readonly
Returns the value of attribute step_name.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(error, retryable: nil, step_name: nil, inputs: {}, backtrace: nil, redact_inputs: [], reactor_name: nil, step_arguments: {}) ⇒ Failure
constructor
rubocop:disable Metrics/ParameterLists.
- #message ⇒ Object
- #retryable? ⇒ Boolean
- #success? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(error, retryable: nil, step_name: nil, inputs: {}, backtrace: nil, redact_inputs: [], reactor_name: nil, step_arguments: {}) ⇒ Failure
rubocop:disable Metrics/ParameterLists
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ruby_reactor.rb', line 44 def initialize(error, retryable: nil, step_name: nil, inputs: {}, backtrace: nil, redact_inputs: [], reactor_name: nil, step_arguments: {}) # rubocop:enable Metrics/ParameterLists @error = error @retryable = if retryable.nil? error.respond_to?(:retryable?) ? error.retryable? : true else retryable end @step_name = step_name @reactor_name = reactor_name @inputs = inputs @step_arguments = step_arguments @backtrace = backtrace || (error.respond_to?(:backtrace) ? error.backtrace : caller) @redact_inputs = redact_inputs end |
Instance Attribute Details
#backtrace ⇒ Object (readonly)
Returns the value of attribute backtrace.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def backtrace @backtrace end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def error @error end |
#inputs ⇒ Object (readonly)
Returns the value of attribute inputs.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def inputs @inputs end |
#reactor_name ⇒ Object (readonly)
Returns the value of attribute reactor_name.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def reactor_name @reactor_name end |
#retryable ⇒ Object (readonly)
Returns the value of attribute retryable.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def retryable @retryable end |
#step_arguments ⇒ Object (readonly)
Returns the value of attribute step_arguments.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def step_arguments @step_arguments end |
#step_name ⇒ Object (readonly)
Returns the value of attribute step_name.
41 42 43 |
# File 'lib/ruby_reactor.rb', line 41 def step_name @step_name end |
Instance Method Details
#failure? ⇒ Boolean
65 66 67 |
# File 'lib/ruby_reactor.rb', line 65 def failure? true end |
#message ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/ruby_reactor.rb', line 73 def msg = [] header = "Error" header += " in reactor '#{reactor_name}'" if reactor_name header += " step '#{step_name}'" if step_name header += ": #{}" msg << header if inputs && !inputs.empty? msg << "Inputs:" inputs.each do |key, value| val = @redact_inputs.include?(key) ? "[REDACTED]" : value.inspect msg << " #{key}: #{val}" end end if step_arguments && !step_arguments.empty? msg << "Step Arguments:" step_arguments.each do |key, value| # We might want to redact step arguments too if they come from redacted inputs # For now, let's assume if the input key matches a redacted input key, it should be redacted # But step arguments have different names. # We can't easily track redaction for step arguments without more metadata. # For now, let's just display them. msg << " #{key}: #{value.inspect}" end end if backtrace msg << "Backtrace:" msg << backtrace.take(5).map { |line| " #{line}" }.join("\n") end msg.join("\n") end |
#retryable? ⇒ Boolean
69 70 71 |
# File 'lib/ruby_reactor.rb', line 69 def retryable? @retryable end |
#success? ⇒ Boolean
61 62 63 |
# File 'lib/ruby_reactor.rb', line 61 def success? false end |
#to_s ⇒ Object
110 111 112 |
# File 'lib/ruby_reactor.rb', line 110 def to_s end |