Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically catch and wrap exceptions thrown in @effect.result functions?

See original GitHub issue

Issue Description

Currently, it looks like any non-Expression exceptions thrown in a effect.result decorated function is re-raised by the decorator. I’m wondering if it might be useful to have the decorator return an Error object instead, wrapping the raised Exception object?

This would reduce the amount of manual conversions from raised exceptions to Error objects, enabling easier interfacing with code/libraries that throw exceptions.

Thoughts? Happy to take a stab at implementing this. Either way, I’m digging this library!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

mrahtzcommented, Feb 20, 2021

@mlw214 I noticed you referenced python/typing#193 on variadic generics in this thread. Heads up that we’ve been working on a draft of a PEP for this in PEP 646. If this is something you still care about, take a read and let us know any feedback in this thread in typing-sig. Thanks!

mlw214commented, Dec 30, 2020

This is great! Thanks for your corrections/input.

One thing I noticed is that the decorator doesn’t appear to work well with the @curried decorator. Personally, I’d like to get them to play nicely together, if possible. I’ll play around with @catch to see if I can make that happen. Regardless, I hope to have a PR for you this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

When to return a Result.Error and when to throw an Exception?
Always throw an Error; Always throw errors and then only wrap them when you want to handle them; Only return recoverable errors, throw...
Read more >
Best Practices for exceptions - .NET - Microsoft Learn
Learn best practices for exceptions, such as using try/catch/finally, handling common conditions without exceptions, and using predefined .
Read more >
error handling - Result object vs throwing exceptions
The best thing you can do when there are multiple return value's is wrap it in a result object. When writing your listener...
Read more >
Why catch and rethrow an exception in C#? - Stack Overflow
To do this you can wrap all of the code in a try/catch/finally. In the finally set the cursor back to the right...
Read more >
Exceptions in coroutines. Cancellation and Exceptions in…
In this article, we'll explain how exceptions are propagated in coroutines and how you can always be in control, including the different ways...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found