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

Typed errors #12

Merged
merged 4 commits into from
Feb 17, 2023
Merged

Typed errors #12

merged 4 commits into from
Feb 17, 2023

Conversation

nomisRev
Copy link
Member

@nomisRev nomisRev commented Feb 14, 2023

This PR adds a draft document for the typed error tutorial. I am not entirely happy with the domain, etc... but I think it covers all the important topics we need to cover in this document.

Sadly with Kotlin 2.0 announced we now that context receivers are still quite some time away, so I didn't mention them on this tutorial which I think should be the backbone of Arrow Core. So be sure to be critical about the domain, examples, and content! And anything missing ☺️

Some missing topics, but we probably better to create separate issues for them and collaborate further on this document. Let's brainstorm a list of topics here before turning them into tickets.

  • zipOrAccumulate
  • Ior
  • Option vs nullable

@nomisRev
Copy link
Member Author

@franciscodr can we invite Jose, and the Kotlin team to review and comment on these PRs as well?

content/learn/typed-errors.md Outdated Show resolved Hide resolved
content/learn/typed-errors.md Outdated Show resolved Hide resolved
content/learn/typed-errors.md Outdated Show resolved Hide resolved
content/learn/typed-errors.md Outdated Show resolved Hide resolved
content/learn/typed-errors.md Outdated Show resolved Hide resolved
@franciscodr
Copy link
Contributor

@franciscodr can we invite Jose, and the Kotlin team to review and comment on these PRs as well?

@nomisRev I have just added the whole Kotlin team, including Jose Gutierrez and Qohat

Co-authored-by: Francisco Diaz <francisco.d@47deg.com>
@nomisRev
Copy link
Member Author

Great suggestions, thank you @pakoito 🙌

<!--- KNIT example-typed-errors-06.kt -->
<!--- TEST assert -->

The type system now tracks that a new error of `OtherError` might have occurred, but that we recovered from any possible errors of `MyError`. This is useful across application layers, or in the service layer, where we might want to `recover` from a `DatabaseError` with a `NetworkError` when we want to load data from the network when a database operation failed.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love the article, and it's perfect for showing how to use the API. I think using names like DatabaseError, NetworkError etc., would also be suitable for all the examples and perhaps more engaging than the current generic examples like MyError.
The architectural layer concerns errors that can be used from top to bottom, showing people how to recover and translate errors from one side to the other are close to the problems users face in their real-world projects. We could have a hierarchy like:

ViewError
ModelError
PersistenceError

Or a similar structure that shows how they are handled and translated through layers until the edge over a use case such as login or similar, which requires validation and handling potential failures.

Copy link
Contributor

@gutiory gutiory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!.
I just left some minor comments. Feel free to use them or not 😄 .

nomisRev and others added 2 commits February 17, 2023 13:45
Co-authored-by: Jose Gutiérrez de Ory <jose.gutierrez@47deg.com>
Co-authored-by: Jose Gutiérrez de Ory <jose.gutierrez@47deg.com>
@nomisRev
Copy link
Member Author

I'm going to merge this PR, we can improve the domain errors @raulraja but I couldn't find a convenient way to update it in this PR easily without making it a lot longer and involving other concerns.

In the Kotlin meeting @franciscodr, @serras and myself discussed adding a page about structuring code. This can perhaps go in the "use-case" section, or another tutorial page explaining layering of applications with typed errors.

I think this document serves as the documentation around Raise, so perhaps Typed Errors is not the right name for this document. We could also rename it Working with Raise.

Feel free to add more comments to this PR after it's closed, and we can turn them into issues/action items.

@nomisRev nomisRev merged commit 5207399 into main Feb 17, 2023
@nomisRev nomisRev deleted the typed-errors branch February 17, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants