https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
s

sergey.trufanov

09/02/2019, 5:30 PM
Hi there. I have a question about clean architecture. Which module (
data
,
domain
,
presentation
) is responsible for handling API errors, for example if I have API method
/login
and it returns error
Email is incorrect
where should I handle it? I guess in repository inside
data
module/layer, but maybe I missed smth.
h

henrikhorbovyi

09/03/2019, 12:13 AM
I use to do that handling on domain layer. It make sense for me because it is near to the
presentation
layer, and
presentation
will only comsume those exceptions coming from
domain
and show it for the user in someway. (I'm not sure if my thoughts are correct. 😄 Just sharing my option) Anyway, I'm curious about other point of view 🙂
r

rkeazor

09/03/2019, 12:04 PM
Domain layer I believe
n

nounours

09/03/2019, 1:12 PM
I would do it in domain layer too. IMHO, data should be responsible to serve raw data, and the domain layer should handle it accordingly to the domain rules, given by the person responsible for it i your org (Product Owner, business, etc etc)
☝️ 1
s

sergey.trufanov

09/03/2019, 2:04 PM
Thank you guys for your answers. Will handle it in
domain
, agree with @nounours
g

ghedeon

09/13/2019, 7:04 AM
Hm, I'd say in
data
and optionally in domain, no? You don't want api exeptions in
domain
because that's dependency leak. You handle it once in
data
, map it to some sort of error model from domain. Then, in
domain
itself you can do something with it, or just pass it to
ui
and
ui
will map it to its own models.
3 Views