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