Make ServantErr throwable
This commit is contained in:
parent
d46cde913c
commit
b1ff2beb8a
1 changed files with 6 additions and 1 deletions
|
@ -2,8 +2,10 @@
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
module Servant.Server.Internal.ServantErr where
|
module Servant.Server.Internal.ServantErr where
|
||||||
|
|
||||||
|
import Control.Exception (Exception)
|
||||||
import qualified Data.ByteString.Char8 as BS
|
import qualified Data.ByteString.Char8 as BS
|
||||||
import qualified Data.ByteString.Lazy as LBS
|
import qualified Data.ByteString.Lazy as LBS
|
||||||
|
import Data.Typeable (Typeable)
|
||||||
import qualified Network.HTTP.Types as HTTP
|
import qualified Network.HTTP.Types as HTTP
|
||||||
import Network.Wai (Response, responseLBS)
|
import Network.Wai (Response, responseLBS)
|
||||||
|
|
||||||
|
@ -11,7 +13,10 @@ data ServantErr = ServantErr { errHTTPCode :: Int
|
||||||
, errReasonPhrase :: String
|
, errReasonPhrase :: String
|
||||||
, errBody :: LBS.ByteString
|
, errBody :: LBS.ByteString
|
||||||
, errHeaders :: [HTTP.Header]
|
, errHeaders :: [HTTP.Header]
|
||||||
} deriving (Show, Eq, Read)
|
} deriving (Show, Eq, Read, Typeable)
|
||||||
|
|
||||||
|
-- Make ServantErr throwable:
|
||||||
|
instance Exception ServantErr
|
||||||
|
|
||||||
responseServantErr :: ServantErr -> Response
|
responseServantErr :: ServantErr -> Response
|
||||||
responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
|
responseServantErr ServantErr{..} = responseLBS status errHeaders errBody
|
||||||
|
|
Loading…
Reference in a new issue