Safe Haskell | None |
---|---|
Language | Haskell2010 |
Hasura.Backends.MSSQL.SQL.Error
Description
Functions and datatypes for interpreting MSSQL database errors.
Synopsis
- data ErrorClass
- data ErrorSubclass a
- = NoSubclass
- | Subclass a
- data DataExceptionSubclass
- data SyntaxErrorOrAccessViolationSubclass
- errorClassCode :: ErrorClass -> Code
- parseErrorClass :: String -> Maybe ErrorClass
- defaultMSSQLTxErrorHandler :: MSSQLTxError -> QErr
- mutationMSSQLTxErrorHandler :: MSSQLTxError -> QErr
- mkMSSQLTxErrorHandler :: (ErrorClass -> Bool) -> MSSQLTxError -> QErr
- odbcExceptionToJSONValue :: ODBCException -> Value
Documentation
data ErrorClass Source #
The top-level error class. Errors in MSSQL are divided into different classes, which are further subdivided into individual error subclasses. It is useful to determine the class of database exception and handle it appropriately.
Constructors
DataException (ErrorSubclass DataExceptionSubclass) | |
IntegrityConstraintViolation | |
SyntaxErrorOrAccessViolation (ErrorSubclass SyntaxErrorOrAccessViolationSubclass) |
Instances
Eq ErrorClass Source # | |
Defined in Hasura.Backends.MSSQL.SQL.Error | |
Show ErrorClass Source # | |
Defined in Hasura.Backends.MSSQL.SQL.Error Methods showsPrec :: Int -> ErrorClass -> ShowS # show :: ErrorClass -> String # showList :: [ErrorClass] -> ShowS # |
data ErrorSubclass a Source #
Constructors
NoSubclass | represents non-specific |
Subclass a | represents known, more specific sub class |
Instances
Eq a => Eq (ErrorSubclass a) Source # | |
Defined in Hasura.Backends.MSSQL.SQL.Error Methods (==) :: ErrorSubclass a -> ErrorSubclass a -> Bool # (/=) :: ErrorSubclass a -> ErrorSubclass a -> Bool # |
data DataExceptionSubclass Source #
Constructors
StringDataRightTruncated | |
NumericValueOutOfRange | |
InvalidDatetimeFormat | |
DatetimeFieldOverflow | |
IntervalFieldOverflow | |
InvalidEscapeCharacter | |
InvalidEscapeSequence |
Instances
Eq DataExceptionSubclass Source # | |
Defined in Hasura.Backends.MSSQL.SQL.Error Methods (==) :: DataExceptionSubclass -> DataExceptionSubclass -> Bool # (/=) :: DataExceptionSubclass -> DataExceptionSubclass -> Bool # | |
Show DataExceptionSubclass Source # | |
Defined in Hasura.Backends.MSSQL.SQL.Error Methods showsPrec :: Int -> DataExceptionSubclass -> ShowS # show :: DataExceptionSubclass -> String # showList :: [DataExceptionSubclass] -> ShowS # |
data SyntaxErrorOrAccessViolationSubclass Source #
Constructors
TableOrViewAlreadyExists | |
TableOrViewNotFound | |
IndexAlreadyExists | |
IndexNotFound | |
ColumnAlreadyExists | |
ColumnNotFound |
Instances
errorClassCode :: ErrorClass -> Code Source #
Assign each error class' subclasses an appropriate API error code
parseErrorClass :: String -> Maybe ErrorClass Source #
Parsing error class and subclass information from a SQLSTATE code. SQLSTATE provides detailed information about the cause of a warning or error. A SQLSTATE consists of 5 chars. They are divided into two parts: the first and second chars contain a class and the following three a subclass.
defaultMSSQLTxErrorHandler :: MSSQLTxError -> QErr Source #
A default transaction error handler where all errors are unexpected.
mutationMSSQLTxErrorHandler :: MSSQLTxError -> QErr Source #
A transaction error handler to be used in constructing mutation transactions, i.e INSERT, UPDATE and DELETE. We expect data exception and integrity constraint violation.
mkMSSQLTxErrorHandler :: (ErrorClass -> Bool) -> MSSQLTxError -> QErr Source #
Constructs a transaction error handler given a predicate that determines which error
classes (and subclasses) are expected and should be reported to the user. All other errors
are considered internal errors.
Example:-
Consider a insert mutation where we insert some data into columns of a table.
Except for the basic data type, such as Boolean, String, Float, Int etc.
we cannot invalidate data any further, such as validating timestamp string format.
In this case, a @DataException
is expected from the database and it is handled and
thrown with proper error message.
odbcExceptionToJSONValue :: ODBCException -> Value Source #
The ODBCException
type has no ToJSON
instance.
This is an attempt to convert the odbc exception to a JSON @Value