module Network.HTTP.Lucu.Abortion
( Abortion
, mkAbortion
, mkAbortion'
, abort
)
where
import Control.Exception
import Control.Monad.Trans
import Data.Ascii (Ascii, CIAscii)
import Data.Collections
import Data.Monoid.Unicode
import Data.Text (Text)
import Network.HTTP.Lucu.Abortion.Internal
import Network.HTTP.Lucu.Response.StatusCode
import Prelude.Unicode
mkAbortion ∷ (StatusCode sc, Foldable f (CIAscii, Ascii))
⇒ sc
→ f
→ Maybe Text
→ Abortion
mkAbortion sc hdrs msg
= Abortion {
aboStatus = fromStatusCode sc
, aboHeaders = fromFoldable hdrs
, aboMessage = msg
}
mkAbortion' ∷ StatusCode sc ⇒ sc → Text → Abortion
mkAbortion' sc msg
= Abortion {
aboStatus = fromStatusCode sc
, aboHeaders = (∅)
, aboMessage = Just msg
}
abort ∷ MonadIO m ⇒ Abortion → m a
abort = liftIO ∘ throwIO