returns: Improve Failure tracibility

dry-rb has a cool feature: tracing failures https://dry-rb.org/gems/dry-monads/1.3/tracing-failures/ We need something similar to improve debugging experience. It might be included into the core, or just into some contrib/ package.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 33 (33 by maintainers)

Most upvoted comments

I think it’s better to patch a method (_get_trace) from _Failure than modify the Failure that’s our Public API! What do you think??

It was a great discussion! I’ll open the PR ASAP

Now this looks like it can be implemented in its final form! @thepabloaguilar thanks a lot for your amazing research work!

This is a hard thing to say, but! I like the monkeypatch solution 😆

I don’t know other way than uses something in the system, but it’s a bad thing because Failure won’t be deterministic.

And, if we monkey patch Failure? Adding a callable or boolean parameter to it, and inside collect_traces we mokey patch Failure with a partially applied that parameter.

def Failure(inner_value, trace):
    ...

@contextmanager
def collect_traces():
    failure_with_trace = partial(Failure, trace=[bool or a callable])
    # make monkey patch

Let’s make this feature ready for production! Awesome work 🎉