-
Notifications
You must be signed in to change notification settings - Fork 1
Error Management Functional Approach
First of all, I'm going to use Arrow library to provide needed data types to manage this kind of approach on error management. By using a Functional approach on error management you are achieving two main things (from my point of view):
- Classes of the Architecture won't need to know if there is an exception until Presentation layer has been reached (where I will just need to manage it, instead of returning it etc)
- We are making our Classes atomic, as we will be always managing the same kind of object (Either or Try) and we won't need to expect exceptions or other unexpected types.
I will use Try to manage possible exceptions for operations like DB accesses or API calls (I know that Try is Deprecated, but for the purpose of the test it provides an easy error management tool and we can simply change it once needed).
- TODO
I will use Either to manage Try responses. Once the Try is returned, I will simply make use of fold to see what is inside (Error or desired data) and then based on that, I will return an Either, that will be opened in the Presentation layer (by Presenters) so we won't care about exceptions until then, when I will make use of handleError method to show a message or make an action depending on the Failure type.
- TODO