Skip to content

Fix source_location in chains #26

@markburns

Description

@markburns

We currently have this which is I think a regression. Not the error itself, but rather the fact that it isn't reporting on the location of the .if, .each, or .chain call within the application, but rather still referring to the gem internals.

It would be better to have a source_location line within the application for each interactor and DSL method call that fires an interactor. run/run!/call/call!

running rspec without --backtrace

    # ./app/interactors/point_of_failure.rb:12:in `call'
    # ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in <module:Somewhere::In::The::App::Code>'

where PointOfFailure is deeply nested call after Somewhere::In::The::App::Code.call!

I.e. instead of running rspec with --backtrace and seeing the following

    # ./app/interactors/point_of_failure.rb:12:in `call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/if_klass.rb:25:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/if_klass.rb:86:in `block in attach_run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:58:in `block (4 levels) in klass'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:57:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:57:in `block (3 levels) in klass'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `each_with_index'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/each_chain.rb:53:in `block (2 levels) in klass'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:27:in `block in call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `each'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactify-0.5.0/lib/interactify/dsl/organizer.rb:19:in `call'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:143:in `block in run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:213:in `block in with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:224:in `run_around_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor/hooks.rb:211:in `with_hooks'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:142:in `run!'
     # /Users/markburns/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/interactor-3.1.2/lib/interactor.rb:76:in `call!'
     # ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in <module:Code>'

we should see something more like (pseudocode) without --backtrace

    # ./app/interactors/point_of_failure.rb:12:in `call'     
    # ./app/interactors/another_caller.rb:11:in `call' in <module:AnotherCaller>'
    # ./app/interactors/some_organizer.rb:11:in `call' in <module:SomeOrganizer>'
    # ./somewhere/in/the/app/code.rb:11:in `block (2 levels) in <module:Somewhere::In::The::App::Code::IfProc345.call>'
    # ./somewhere/in/the/app/code.rb:10:in `block (2 levels) in <module:Somewhere::In::The::App::Code::EachResource1234.call>'
    # ./somewhere/in/the/app/code.rb:9:in `block (2 levels) in <module:Somewhere::In::The::App::Code>'

Then have a trace as above but with DSL internal interspersed in the stack trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions