module Network.HTTP2.Client.Exceptions (
    ClientIO
  , ClientError(..)
  , runClientIO
  , module Control.Monad.Except
  ) where

import           Control.Exception (Exception)
import           Control.Monad.Except (ExceptT, runExceptT, throwError, lift)

type ClientIO = ExceptT ClientError IO

runClientIO :: ClientIO a -> IO (Either ClientError a)
runClientIO :: ClientIO a -> IO (Either ClientError a)
runClientIO = ClientIO a -> IO (Either ClientError a)
forall e (m :: * -> *) a. ExceptT e m a -> m (Either e a)
runExceptT

-- | A set of errors as observed from the client.
data ClientError = EarlyEndOfStream
  -- ^ We received a TCP end-of-stream and there will be no further read-IOs possible on the connection.
  deriving (Int -> ClientError -> ShowS
[ClientError] -> ShowS
ClientError -> String
(Int -> ClientError -> ShowS)
-> (ClientError -> String)
-> ([ClientError] -> ShowS)
-> Show ClientError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClientError] -> ShowS
$cshowList :: [ClientError] -> ShowS
show :: ClientError -> String
$cshow :: ClientError -> String
showsPrec :: Int -> ClientError -> ShowS
$cshowsPrec :: Int -> ClientError -> ShowS
Show,Eq ClientError
Eq ClientError
-> (ClientError -> ClientError -> Ordering)
-> (ClientError -> ClientError -> Bool)
-> (ClientError -> ClientError -> Bool)
-> (ClientError -> ClientError -> Bool)
-> (ClientError -> ClientError -> Bool)
-> (ClientError -> ClientError -> ClientError)
-> (ClientError -> ClientError -> ClientError)
-> Ord ClientError
ClientError -> ClientError -> Bool
ClientError -> ClientError -> Ordering
ClientError -> ClientError -> ClientError
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ClientError -> ClientError -> ClientError
$cmin :: ClientError -> ClientError -> ClientError
max :: ClientError -> ClientError -> ClientError
$cmax :: ClientError -> ClientError -> ClientError
>= :: ClientError -> ClientError -> Bool
$c>= :: ClientError -> ClientError -> Bool
> :: ClientError -> ClientError -> Bool
$c> :: ClientError -> ClientError -> Bool
<= :: ClientError -> ClientError -> Bool
$c<= :: ClientError -> ClientError -> Bool
< :: ClientError -> ClientError -> Bool
$c< :: ClientError -> ClientError -> Bool
compare :: ClientError -> ClientError -> Ordering
$ccompare :: ClientError -> ClientError -> Ordering
$cp1Ord :: Eq ClientError
Ord,ClientError -> ClientError -> Bool
(ClientError -> ClientError -> Bool)
-> (ClientError -> ClientError -> Bool) -> Eq ClientError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClientError -> ClientError -> Bool
$c/= :: ClientError -> ClientError -> Bool
== :: ClientError -> ClientError -> Bool
$c== :: ClientError -> ClientError -> Bool
Eq)
instance Exception ClientError -- For people who want to rethrow using Control.Exception