Module: Trailblazer::Developer::Wtf
- Defined in:
- lib/trailblazer/developer/wtf.rb,
lib/trailblazer/developer/wtf/renderer.rb
Defined Under Namespace
Class Method Summary collapse
-
.invoke(activity, ctx, flow_options, present_options: {}, **circuit_options) ⇒ Object
Run activity with tracing enabled and inject a mutable Stack instance.
Class Method Details
.invoke(activity, ctx, flow_options, present_options: {}, **circuit_options) ⇒ Object
Run activity with tracing enabled and inject a mutable Stack instance. This allows to display the trace even when an exception happened
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/trailblazer/developer/wtf.rb', line 17 def invoke(activity, (ctx, ), present_options: {}, **) ||= {} stack = Trace::Stack.new # unfortunately, we need this mutable object before things break. complete_stack, signal, (ctx, ) = Trace.invoke( activity, [ctx, .merge(stack: stack)], ** ) return signal, [ctx, ], ensure # incomplete_stack = flow_options[:stack] incomplete_stack = stack # in 99%, exception_source is a {Captured::Input}. exception_source = incomplete_stack.to_a.last # DISCUSS: in most cases, this is where the problem has happened. # However, what if an error happens in, say, an input filter? TODO: test this complete_stack = Exception::Stack.complete(incomplete_stack) # TODO: only in case of exception! puts Trace::Present.( complete_stack, # we can hand in options per node, identified by their captured_input part. node_options: { exception_source => {data: {exception_source: true}}, # goes to {Debugger::Node.build} }, renderer: Wtf::Renderer, color_map: Wtf::Renderer::DEFAULT_COLOR_MAP.merge( [:color_map] || {} ), style: {exception_source => [:red, :bold]}, **, # TODO: test. ) end |