Aborting the computation of Network.HTTP.Lucu.Rsrc
in any IO
monads.
- data Abortion
- mkAbortion :: (StatusCode sc, Foldable f (CIAscii, Ascii)) => sc -> f -> Maybe Text -> Abortion
- mkAbortion' :: StatusCode sc => sc -> Text -> Abortion
- abort :: MonadIO m => Abortion -> m a
Documentation
Abortion
is an Exception
that aborts the execution of
Network.HTTP.Lucu.Rsrc
monad with a StatusCode
, additional
response headers, and an optional message text.
- If the
Network.HTTP.Lucu.Rsrc
is in the Deciding Header or any precedent states, throwing anAbortion
affects the HTTP response to be sent to the client. - Otherwise it's too late to overwrite the HTTP response so the
only possible thing the system can do is to dump the exception
to the stderr. See
cnfDumpTooLateAbortionToStderr
.
Note that the status code doesn't necessarily have to satisfy
isError
so you can abuse this exception for redirections as well
as error reporting e.g.
Network.HTTP.Lucu.abort
$
Network.HTTP.Lucu.mkAbortion
MovedPermanently
[("Location", "http:example.net/")] (Just
"It's been moved to example.net.")
mkAbortion :: (StatusCode sc, Foldable f (CIAscii, Ascii)) => sc -> f -> Maybe Text -> AbortionSource
Construct an Abortion
with additional headers and an optional
message text.
mkAbortion' :: StatusCode sc => sc -> Text -> AbortionSource
Construct an Abortion
without any additional headers but with a
message text.