i'm struggling achieving following goal: have api requests typed in manner return either desired value, or error when status code wasn't indicating success, or when auth token has been invalid etc: either string r
.
now, don't want care when i'm eval
ing components queries. interested in happy path (expected errors invalid logon attempt considered happy path, want keep unexpected stuff out of it), , errors should handled uniformily , globally (sending notification bus).
for this, i've created transformer stack:
type app = readert env (exceptt string (aff appeffects))
now, use runui
, needed provide natural transformation used hoist
(unless i'm missing other possibilities):
runapp :: env -> app ~> aff appeffects runapp env app = res <- runexceptt $ runreadert app env case res of right r -> pure unit left err -> bus.write err env.bus -- return here?
because we're using ~>
here, we're forced retain return type, left
case don't have @ hand!
how 1 tackle such requirement? reiterate - want able 'cancel' evaluation of component query when executed action encounters error, want silently , handle top.
you have exceptional case current thread can't continue, thing throw exception in aff
using throwerror :: forall eff a. error -> aff eff a
.
Comments
Post a Comment