https://kotlinlang.org logo
Title
o

Omar Qadour

04/07/2022, 5:11 PM
Hi guys, where should i handle networking errors with the api in the MVVM pattern?
i

ildar.i [Android]

04/07/2022, 5:17 PM
o

Omar Qadour

04/07/2022, 5:45 PM
Thank you very much :)
c

Casey Brooks

04/07/2022, 5:56 PM
Yeah, I’d say the same. Handle API errors within the Repository and expose a “result type” from the Repository, rather than throwing an exception from the Repository.
❤️ 3
o

Omar Qadour

04/07/2022, 6:41 PM
Okay, so i have to make an extra class, let's say "SafeApiRequest", then a function in it to make the request and to throw an exception, if needed. Then i extend this class in my repository and make the api call through it. Is that right?
i

ildar.i [Android]

04/07/2022, 8:11 PM
You can FP all the way and leave only a function