Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help needed: error handling #1881

Open
jakub-borusewicz opened this issue Jul 21, 2024 · 1 comment
Open

Help needed: error handling #1881

jakub-borusewicz opened this issue Jul 21, 2024 · 1 comment

Comments

@jakub-borusewicz
Copy link

Hello!
I'm trying to introduce returns to my new side-project, but it's a bit hard to wrap my head around this library after working for years with OOP.

What I want to do specifically is to implement top-level error handling, where I implement some my_error_handler_func to be composed with IOResult that could contain result of domain logic (let say it's str), or some DomainError, according to given schema (where -> means some method of composition, and => means returning result)

IOResult[str, DomainError] -> my_error_handler_func => str

Important: I would like my_error_handler_func to have access to all of the context necessary to debug the error, if result is IOFailure (so I guess my_error_handler_func should have access to both DomainError itself and IOResult.trace)

What would be recommended way of implementing that?

@jakub-borusewicz
Copy link
Author

Additional question - what would be recommended way of turning IOResult[str, DomainError] into IO[str] if result is IOSuccess[str] or to run my_error_handler_func if result is 'IOFailure[DomainError]`?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant