{-# language DeriveAnyClass #-}
{-# language DerivingStrategies #-}

module Http.Exchange.Types
  ( HttpException(..)
  ) where

import qualified Control.Exception as E

-- | Exceptions that occur when decoding an HTTP response.
-- If this happens, the only way to proceed is to
-- shut down the connection. Either the server does not
-- speak HTTP correct, or there is a mistake in this libary.
data HttpException
  = ChunkTooLarge
  | ChunkedBodyEndOfInput
  | NonchunkedBodyEndOfInput
  | ContentLengthDuplicated
  | ContentLengthMalformed
  | ContentLengthTooLarge
  | ExpectedCrlfAfterChunk
  | ExpectedCrlfAfterChunkLength
  | ExpectedCrlfBeforeChunkLength
  | HeadersMalformed
  | HeadersEndOfInput
  | HeadersTooLarge
  | ImplementationMistake
    -- ^ If this one happens, there is a mistake in this
    -- library.
  | NonNumericChunkLength
  | PipelinedResponses
  | TransferEncodingUnrecognized
  | TransferEncodingDuplicated
  deriving stock (Int -> HttpException -> ShowS
[HttpException] -> ShowS
HttpException -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HttpException] -> ShowS
$cshowList :: [HttpException] -> ShowS
show :: HttpException -> String
$cshow :: HttpException -> String
showsPrec :: Int -> HttpException -> ShowS
$cshowsPrec :: Int -> HttpException -> ShowS
Show)
  deriving anyclass (Show HttpException
Typeable HttpException
SomeException -> Maybe HttpException
HttpException -> String
HttpException -> SomeException
forall e.
Typeable e
-> Show e
-> (e -> SomeException)
-> (SomeException -> Maybe e)
-> (e -> String)
-> Exception e
displayException :: HttpException -> String
$cdisplayException :: HttpException -> String
fromException :: SomeException -> Maybe HttpException
$cfromException :: SomeException -> Maybe HttpException
toException :: HttpException -> SomeException
$ctoException :: HttpException -> SomeException
E.Exception)