“处理”;“对等端重置连接”;haskell'中的错误;雷克图书馆

“处理”;“对等端重置连接”;haskell'中的错误;雷克图书馆,haskell,exception,exception-handling,Haskell,Exception,Exception Handling,我正在使用Haskell的库发出多个GET请求。我想处理连接错误,重试次数有限。我认为这样做会奏效: getRetried url = retried 0 where maxRetries = 2 retried retries | retries >= maxRetries = throwError $ error "number of retries exceeded" | otherwise

我正在使用Haskell的库发出多个GET请求。我想处理连接错误,重试次数有限。我认为这样做会奏效:

getRetried url = retried 0
    where maxRetries = 2
          retried retries | retries >= maxRetries = throwError $ error "number of retries exceeded" 
                          | otherwise             = catchError (get url) (\_ -> (putStrLn "retrying") >> (retried (retries + 1) ) )
但它会不时出现以下错误:

*** Exception: InternalIOException recv: resource vanished (Connection reset by peer)

我错过了什么?
catchError
不是处理错误的正确方法吗?

为什么
thrower。错误
?为了详细说明前面的注释,
错误
创建了一个“底部值”,该值对应于一个
异常
,该异常只能由
控件.Exception.catch等捕获。您必须通过直接提供异常来使用throwError:
throwError$ErrorCall“…”
(当然,您应该定义自己的异常类型。异常的来源不是
error
,但是,它是在其他地方(没有完整的代码就不可能知道)-您仍然可以通过类似
error的方式捕捉到这一点(试试$…)