Skip to content

Conversation

Jeehut
Copy link
Member

@Jeehut Jeehut commented Dec 18, 2024

Fixes #20.

Apart from introducing new error types, I've also decided to make Throwable require Sendable conformance so errors can be thrown and passed around in concurrent code. Compared to the state I've shown you in our call, I have vastly improved the docs and also adjusted the error messages to be more useful.

@n0rthk1n9
Copy link
Collaborator

I don't quite understand, what exactly Sendable is doing, thats something what we can talk about next time, but apart from that this looks fine and can be merged

@Jeehut
Copy link
Member Author

Jeehut commented Jan 14, 2025

@n0rthk1n9 Apple describes a type that conforms to the Sendable protocol as "A thread-safe type whose values can be shared across arbitrary concurrent contexts without introducing a risk of data races." In other words, it means that the type is able to ensure values of the type can't be accessed from multiple places at the same time, which can lead to data races. Because errors are often thrown in other threads than the main thread, it's good to require Sendable conformance so we can create a UI that can read the error. And because errors are always read-only types like enums or structs, they all conform to Sendable automatically.

It's more a "making it future-proof" topic right now since Swift concurrency checking in Swift 6 is not very strict yet, but as Apple iterates on it, it will become more and more important and more developers will know what it is.

Thank you for approving, merging then! 🎉

@Jeehut Jeehut merged commit db8a7d4 into main Jan 14, 2025
1 check passed
@Jeehut Jeehut deleted the wip/common-errors branch January 14, 2025 10:52
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.

ErrorKit: Provide built-in error enums for many common tasks with built-in error descriptions that are localized

2 participants