Automatically catch and wrap exceptions thrown in @effect.result functions?
See original GitHub issueIssue 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:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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!
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.