{-# LANGUAGE OverloadedStrings #-}
module Data.Morpheus.Error.Internal
( internalTypeMismatch
, internalError
, internalResolvingError
)
where
import Data.Text ( pack )
import Data.Semigroup ( (<>) )
import Data.Morpheus.Error.Utils ( globalErrorMessage )
import Data.Morpheus.Types.Internal.Resolving.Core
( Eventless
, Failure(..)
)
import Data.Morpheus.Types.Internal.AST.Base
( GQLErrors
, Message
)
import Data.Morpheus.Types.Internal.AST.Value
( ValidValue )
internalError :: Message -> Eventless a
internalError x = failure $ globalErrorMessage $ "INTERNAL ERROR: " <> x
internalResolvingError :: Message -> GQLErrors
internalResolvingError = globalErrorMessage . ("INTERNAL ERROR:" <>)
internalTypeMismatch :: Message -> ValidValue -> Eventless a
internalTypeMismatch text jsType =
internalError $ "Type mismatch " <> text <> pack (show jsType)