-
-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Problem Statement
You already have a handful of built-in error mappings for common Apple frameworks like URLSession, FileManager, and CoreData. Functions like mapToThrowable, userFriendlyFoundationMessage and others.
These global handlers are called within userFriendlyMessage to try and map to the best possible error message. Awesome.
What would be nice is if I was able to provide my own "error matchers" to map an Error to a Throwable.
The purpose of this is to:
- Enable an ecosystem of third-party libraries that provide extensions to this primary product. Providing mappings to errors thrown by many third parties, no matter what they be, and without requiring adoption upstream.
- Adds a centralised way to map error messages within a product, which can be useful to ease in initial onboarding, and in cases where you want to provide backend messages.
Suggested Solution
protocol ThrowableMappingProvider {
func mapToThrowable(error: Error) -> Throwable? // Where `nil` is unhandled, and falls to the next.
}
ErrorKitMapper.register(MyMappingProvider()) // this would store as an array, first registered gets checked first.
DandyLyons
Metadata
Metadata
Assignees
Labels
No labels