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