Hi,
I am using a dry-effect in my controller (hanami) to provide a Reader which is used to provide scoping information to the repositories e.g. organisation_id
.
I have noticed that when an exception is thrown, my stacktrace has stack information all the way up to the point I use the dry-effect which prevents me from seeing which controller the error originated from.
I can solve this by wrapping the call method at a rack level using a dry-effect Reader which does not provide anything but just ensuring the dry-effect reader happening further up the stack is wrapped.
e.g.
require 'dry/effects'
class RootDryEffect
include Dry::Effects::Handler.State(:root)
def initialize(app)
@app = app
end
def call(env)
_, response = with_root({}) do
@app.call(env)
end
response
end
end
and then calling it with:
middleware.use RootDryEffect
Is there a better way to achieve this? / downsides to this approach?