{-# LANGUAGE OverloadedStrings #-}
module Data.Morpheus.Error.Internal
( internalTypeMismatch
, internalArgumentError
, internalUnknownTypeMessage
, internalError
, internalErrorT
) where
import Data.Morpheus.Error.Utils (globalErrorMessage)
import Data.Morpheus.Types.Internal.Validation (GQLErrors, ResolveT, failResolveT)
import Data.Morpheus.Types.Internal.Value (Value (..))
import Data.Text (Text)
import qualified Data.Text as T (concat, pack)
internalError :: Text -> Either GQLErrors b
internalError x = Left $ globalErrorMessage $ T.concat ["INTERNAL ERROR: ", x]
internalErrorT :: Monad m => Text -> ResolveT m b
internalErrorT x =
failResolveT $ globalErrorMessage $ T.concat ["INTERNAL ERROR: ", x]
internalUnknownTypeMessage :: Text -> GQLErrors
internalUnknownTypeMessage x =
globalErrorMessage $
T.concat ["type did not not found, but was defined by Schema", x]
internalArgumentError :: Text -> Either GQLErrors b
internalArgumentError x = internalError $ T.concat ["Argument ", x]
internalTypeMismatch :: Text -> Value -> Either GQLErrors b
internalTypeMismatch text jsType =
internalError $ T.concat ["Type mismatch ", text, T.pack $ show jsType]