legion-discovery-0.3.0.0: src/Network/Legion/Discovery/HttpError.hs
{- |
This module contains a `ScottyError` error type that short-cuts to http
response types.
-}
module Network.Legion.Discovery.HttpError (
HttpError(..),
) where
import Control.Exception (Exception)
import Data.Text (Text, pack)
import Data.Text.Lazy (fromStrict)
import Network.HTTP.Types (Status)
import Web.Scotty.Trans (ScottyError, stringError, showError)
data HttpError
= Transient Status Text
| Critical Text
deriving (Show)
instance Exception HttpError
instance ScottyError HttpError where
stringError = Critical . pack
showError (Transient _ msg) = fromStrict msg
showError (Critical msg) = fromStrict msg