I am a beginner in iOS development, and trying to follow a best practice for error management in Combine framework for some use case when working with MVVM pattern in your project.
So let’s imagine a use case.
We have repository that has several methods, each try different sources to find some data.
So, we have some data that can be found in different sources, let's say sourceA, sourceB and sourceC, etc... and each source can produce its own Error type errorA, errorB, errorC, etc...
Repository.methodX
- try sourceA -> can produce errorA
- try sourceB -> can produce errorB
- try sourceC -> can produce errorC
Repository.methodY
- try sourceA -> can produce errorA
- try sourceD -> can produce errorD
- try sourceC -> can produce errorC
Repository.methodZ
- ... and so on
So in the repository .. we can at the end of the stream make mapError to some kind of general error type.
So this kind of general error type, what it should be? a one big error type for all methods in the repository? .. or an small error type for each method?
How to think about it .. I am asking so I can learn how to accomplish error management in Combine in a clean way.
NOTE: Picture included with the style I follow in MVVM pattern
