5 -- |Aborting the computation of 'Network.HTTP.Lucu.Resource.Resource'
6 -- in any 'Prelude.IO' monads or arrows.
7 module Network.HTTP.Lucu.Abortion
15 import Control.Exception
16 import Control.Monad.Trans
17 import Data.Ascii (Ascii, CIAscii)
18 import Data.Collections
19 import Data.Monoid.Unicode
20 import Data.Text (Text)
21 import Network.HTTP.Lucu.Abortion.Internal
22 import Network.HTTP.Lucu.Response
23 import Prelude.Unicode
25 -- |Construct an 'Abortion' with additional headers and an optional
27 mkAbortion ∷ (StatusCode sc, Foldable f (CIAscii, Ascii))
32 {-# INLINE mkAbortion #-}
33 mkAbortion sc hdrs msg
35 aboStatus = fromStatusCode sc
36 , aboHeaders = fromFoldable hdrs
40 -- |Construct an 'Abortion' without any additional headers but with a
42 mkAbortion' ∷ StatusCode sc ⇒ sc → Text → Abortion
43 {-# INLINE mkAbortion' #-}
46 aboStatus = fromStatusCode sc
48 , aboMessage = Just msg
51 -- |Throw an 'Abortion' in a 'MonadIO', including the very
52 -- 'Network.HTTP.Lucu.Resource.Resource' monad.
53 abort ∷ MonadIO m ⇒ Abortion → m a
55 abort = liftIO ∘ throwIO