haskell - How to handle all possible errors cleanly when using HTTP conduit? -


i have code looks this:

retryontimeout :: io -> io retryontimeout action = catch action $ \responsetimeout ->                              putstrln "timed out. trying again."                                threaddelay 5000000                                action  

the problem there lot of other constructors of httpexception, , keep trying again, regardless of error is. if replace responsetimeout _ compile error because cannot deduce type of exception.

i don't want provide type signature exception handler either.

i know it's not much duplication, adding case _ feels wrong because it's saying: if exception responsetimeout x, if exception else do same thing. there concise way use wildcard still let compiler know type is?

if don't care exception value it's totally fine use _ you'll need use scopedtypevariables or let clause specify type want.

{-# language scopedtypevariables #-}  retryontimeout :: io -> io retryontimeout action = catch action $ \ (_ :: httpexception) ->   putstrln "timed out. trying again."   threaddelay 5000000   action 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -