Closed ondrap closed 7 years ago
Are you sure that error doesn't go into MonadError ServantError
, most expected errors go there.
http://hackage.haskell.org/package/servant-client-0.10/docs/Servant-Client.html#t:ServantError
It does, sorry, my fault. It's somewhat confusing having both...
At least in my usage where web-server uses servant-client to make further requests I never catch unchecker (MonadCatch
) exceptions, they are rare and unrecoverable (and framework fails original request with 500 internal error), so far I never seen. Based on our monitoring 500 "never' happens.
(Disclaimer: Data.Binary.decode
throws impure exceptions, and those I do sometimes catch, I have mixed feelings about that impurity though).
OTOH, if you think there is some recoverable error, than IMO we should extend ServantError
. Please open another issue if it's so.
Just want to make a quick note for people like me running into this "exception in ClientM not being caught" problem: make sure to use things from Control.Monad.Except
, which is meant for receiving ServantError
s, rather than Control.Monad.Catch
, which is more similar to Exception handling in IO.
I do however feel it's a bit confusing that ServantError
is an instance of Exception
, and that got me straight into thinking about exceptions handling in IO and spent few hours figuring out why catch
caught nothing.
Something seems to be broken in the
ClientM
monad fromservant-client
.The
onException
(andcatch
and all the others) just seems to be ignored. I tried this on servant 0.9.1.1 quite thoroughly, it seems not to work with 0.10 either (the MonadBaseControl doesn't seem to help, I haven't tested this a lot).The
MonadCatch
is automatically derived, so this might be an error somewhere else.