package Ġxyz . mir age . app . business . inter actors . account Ċ Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . catch Ċ import Ġkotlinx . coroutines . flow . flow Ċ import Ġxyz . mir age . app . business . datas ources . cache . account . Account Dao Ċ import Ġxyz . mir age . app . business . datas ources . network . core . handle UseCase Exception Ċ import Ġxyz . mir age . app . business . datas ources . network . main . account . Account Service Ċ import Ġxyz . mir age . app . business . domain . core . Data State Ċ import Ġxyz . mir age . app . business . domain . core . Error Handling . Companion . ERROR _ UN ABLE _ TO _ RE TR IE VE _ ACCOUNT _ DETAILS Ċ import Ġxyz . mir age . app . business . domain . models . Account Ċ Ċ class ĠGet Account ( ĊĠĠĠ Ġprivate Ġval Ġservice : ĠAccount Service , ĊĠĠĠ Ġprivate Ġval Ġcache : ĠAccount Dao , Ċ ) Ġ{ ĊĠĠĠ Ġfun Ġexecute (): ĠFlow < Data State < Account >> Ġ= Ġflow Ġ{ ĊĠĠĠĠĠĠĠ Ġemit ( Data State . loading < Account >()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġget Ġfrom Ġnetwork ĊĠĠĠĠĠĠĠ Ġval Ġaccount Ġ= Ġservice . getCurrent (). to Account () ĊĊĠĠĠĠĠĠĠ Ġ// Ġupdate / insert Ġinto Ġthe Ġcache ĊĠĠĠĠĠĠĠ Ġcache . insert Or Ignore ( account . to Entity ()) ĊĊĠĠĠĠĠĠĠ Ġ// Ġemit Ġfrom Ġcache ĊĠĠĠĠĠĠĠ Ġval Ġcached Account Ġ= Ġcache . search ById ( account . id )?. to Account () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠException ( ERROR _ UN ABLE _ TO _ RE TR IE VE _ ACCOUNT _ DETAILS ) ĊĊĠĠĠĠĠĠĠ Ġemit ( Data State . data ( response Ġ= Ġnull , Ġcached Account )) ĊĠĠĠ Ġ}. catch Ġ{ Ġe Ġ-> ĊĠĠĠĠĠĠĠ Ġemit ( handle UseCase Exception ( e )) ĊĠĠĠ Ġ} Ċ } Ċ