diff options
author | stuebinm | 2022-08-27 01:45:12 +0200 |
---|---|---|
committer | stuebinm | 2022-08-27 01:45:12 +0200 |
commit | a4045a5b0a898042cd78eba9b22550c965a1bbd9 (patch) | |
tree | 337277b15c7fba9ea857cdd388ff1b2c84d9101b /lib/Server/Util.hs | |
parent | 6fa510d35f0ca8738df7274bf6f02ad75a987f60 (diff) |
controlroom: lots of pretty little knobs
(also some database schema changes, for good measure)
Diffstat (limited to '')
-rw-r--r-- | lib/Server/Util.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/Server/Util.hs b/lib/Server/Util.hs index a7a358e..5bfba52 100644 --- a/lib/Server/Util.hs +++ b/lib/Server/Util.hs @@ -1,15 +1,21 @@ {-# LANGUAGE FlexibleContexts #-} -- | mostly the monad the service runs in -module Server.Util (Service, ServiceM, runService) where +module Server.Util (Service, ServiceM, runService, sendErrorMsg) where import Control.Monad.Logger (LoggingT, runStderrLoggingT) +import qualified Data.Aeson as A import Data.ByteString (ByteString) -import Servant (Handler, ServerError, ServerT, err302, - errHeaders, throwError) +import Data.Text (Text) +import Servant (Handler, ServerError, ServerT, err404, + errBody, errHeaders, throwError) type ServiceM = LoggingT Handler type Service api = ServerT api ServiceM runService :: ServiceM a -> Handler a runService = runStderrLoggingT + +sendErrorMsg :: Text -> ServiceM a +sendErrorMsg msg = throwError err404 + { errBody = A.encode $ A.object ["error" A..= (404 :: Int), "msg" A..= msg] } |