{-# LINE 1 "src/Database/EJDB2/Result.hsc" #-}
{-# LANGUAGE CPP #-}
module Database.EJDB2.Result where
import Foreign
import Foreign.C.Types
type RC = CUIntMax
checkRC :: RC -> IO ()
checkRC rc = do
let result = decodeRC rc
if result == Ok then return () else fail $ show result
checkRCFinally :: IO a -> RC -> IO a
checkRCFinally computation rc = do
let result = decodeRC rc
if result == Ok
then computation
else do
computation
fail $ show result
data Result =
Ok
| ErrorFail
| ErrorErrno
| ErrorIoErrno
| ErrorNotExists
| ErrorReadonly
| ErrorAlreadyOpened
| ErrorThreading
| ErrorThreadingErrno
| ErrorAssertion
| ErrorInvalidHandle
| ErrorOutOfBounds
| ErrorNotImplemented
| ErrorAlloc
| ErrorInvalidState
| ErrorNotAligned
| ErrorFalse
| ErrorInvalidArgs
| ErrorOverflow
| ErrorInvalidValue
| ErrorNotFound
| ErrorKeyExists
| ErrorMaxkvsz
| ErrorCorrupted
| ErrorDupValueSize
| ErrorKeyNumValueSize
| ErrorIncompatibleDbMode
| ErrorIncompatibleDbFormat
| ErrorCorruptedWalFile
| ErrorValueCannotBeIncremented
| ErrorWalModeRequired
| ErrorBackupInProgress
| ErrorInvalidBuffer
| ErrorCreation
| ErrorInvalid
| ErrorParseJson
| ErrorParseUnquotedString
| ErrorParseInvalidCodepoint
| ErrorParseInvalidUtf8
| ErrorJsonPointer
| ErrorPathNotFound
| ErrorPatchInvalid
| ErrorPatchInvalidOp
| ErrorPatchNovalue
| ErrorPatchTargetInvalid
| ErrorPatchInvalidValue
| ErrorPatchInvalidArrayIndex
| ErrorNotAnObject
| ErrorPatchTestFailed
| ErrorInvalidCollectionName
| ErrorInvalidCollectionMeta
| ErrorInvalidCollectionIndexMeta
| ErrorInvalidIndexMode
| ErrorMismatchedIndexUniquenessMode
| ErrorUniqueIndexConstraintViolated
| ErrorCollectionNotFound
| ErrorTargetCollectionExists
| ErrorPatchJsonNotObject
| ErrorQueryParse
| ErrorInvalidPlaceholder
| ErrorUnsetPlaceholder
| ErrorRegexpInvalid
| ErrorRegexpCharset
| ErrorRegexpSubexp
| ErrorRegexpSubmatch
| ErrorRegexpEngine
| ErrorSkipAlreadySet
| ErrorLimitAlreadySet
| ErrorOrderbyMaxLimit
| ErrorNoCollection
| ErrorInvalidPlaceholderValueType
deriving ( Eq, Show )
decodeRC :: RC -> Result
decodeRC rc = case rc of
0 -> Ok
{-# LINE 102 "src/Database/EJDB2/Result.hsc" #-}
70000 -> ErrorFail
{-# LINE 103 "src/Database/EJDB2/Result.hsc" #-}
70001 -> ErrorErrno
{-# LINE 104 "src/Database/EJDB2/Result.hsc" #-}
70002 -> ErrorIoErrno
{-# LINE 105 "src/Database/EJDB2/Result.hsc" #-}
70003 -> ErrorNotExists
{-# LINE 106 "src/Database/EJDB2/Result.hsc" #-}
70004 -> ErrorReadonly
{-# LINE 107 "src/Database/EJDB2/Result.hsc" #-}
70005 -> ErrorAlreadyOpened
{-# LINE 108 "src/Database/EJDB2/Result.hsc" #-}
70006 -> ErrorThreading
{-# LINE 109 "src/Database/EJDB2/Result.hsc" #-}
70007 -> ErrorThreadingErrno
{-# LINE 110 "src/Database/EJDB2/Result.hsc" #-}
70008 -> ErrorAssertion
{-# LINE 111 "src/Database/EJDB2/Result.hsc" #-}
70009 -> ErrorInvalidHandle
{-# LINE 112 "src/Database/EJDB2/Result.hsc" #-}
70010 -> ErrorOutOfBounds
{-# LINE 113 "src/Database/EJDB2/Result.hsc" #-}
70011 -> ErrorNotImplemented
{-# LINE 114 "src/Database/EJDB2/Result.hsc" #-}
70012 -> ErrorAlloc
{-# LINE 115 "src/Database/EJDB2/Result.hsc" #-}
70013 -> ErrorInvalidState
{-# LINE 116 "src/Database/EJDB2/Result.hsc" #-}
70014 -> ErrorNotAligned
{-# LINE 117 "src/Database/EJDB2/Result.hsc" #-}
70015 -> ErrorFalse
{-# LINE 118 "src/Database/EJDB2/Result.hsc" #-}
70016 -> ErrorInvalidArgs
{-# LINE 119 "src/Database/EJDB2/Result.hsc" #-}
70017 -> ErrorOverflow
{-# LINE 120 "src/Database/EJDB2/Result.hsc" #-}
70018 -> ErrorInvalidValue
{-# LINE 121 "src/Database/EJDB2/Result.hsc" #-}
75001 -> ErrorNotFound
{-# LINE 122 "src/Database/EJDB2/Result.hsc" #-}
75002 -> ErrorKeyExists
{-# LINE 123 "src/Database/EJDB2/Result.hsc" #-}
75003 -> ErrorMaxkvsz
{-# LINE 124 "src/Database/EJDB2/Result.hsc" #-}
75004 -> ErrorCorrupted
{-# LINE 125 "src/Database/EJDB2/Result.hsc" #-}
75005 -> ErrorDupValueSize
{-# LINE 126 "src/Database/EJDB2/Result.hsc" #-}
75006 -> ErrorKeyNumValueSize
{-# LINE 127 "src/Database/EJDB2/Result.hsc" #-}
75007 -> ErrorIncompatibleDbMode
{-# LINE 128 "src/Database/EJDB2/Result.hsc" #-}
75008 -> ErrorIncompatibleDbFormat
{-# LINE 129 "src/Database/EJDB2/Result.hsc" #-}
75009 -> ErrorCorruptedWalFile
{-# LINE 130 "src/Database/EJDB2/Result.hsc" #-}
75010 -> ErrorValueCannotBeIncremented
{-# LINE 131 "src/Database/EJDB2/Result.hsc" #-}
75011 -> ErrorWalModeRequired
{-# LINE 132 "src/Database/EJDB2/Result.hsc" #-}
75012 -> ErrorBackupInProgress
{-# LINE 133 "src/Database/EJDB2/Result.hsc" #-}
86001 -> ErrorInvalidBuffer
{-# LINE 134 "src/Database/EJDB2/Result.hsc" #-}
86002 -> ErrorCreation
{-# LINE 135 "src/Database/EJDB2/Result.hsc" #-}
86003 -> ErrorInvalid
{-# LINE 136 "src/Database/EJDB2/Result.hsc" #-}
86004 -> ErrorParseJson
{-# LINE 137 "src/Database/EJDB2/Result.hsc" #-}
86005 -> ErrorParseUnquotedString
{-# LINE 138 "src/Database/EJDB2/Result.hsc" #-}
86006 -> ErrorParseInvalidCodepoint
{-# LINE 139 "src/Database/EJDB2/Result.hsc" #-}
86007 -> ErrorParseInvalidUtf8
{-# LINE 140 "src/Database/EJDB2/Result.hsc" #-}
86008 -> ErrorJsonPointer
{-# LINE 141 "src/Database/EJDB2/Result.hsc" #-}
86009 -> ErrorPathNotFound
{-# LINE 142 "src/Database/EJDB2/Result.hsc" #-}
86010 -> ErrorPatchInvalid
{-# LINE 143 "src/Database/EJDB2/Result.hsc" #-}
86011 -> ErrorPatchInvalidOp
{-# LINE 144 "src/Database/EJDB2/Result.hsc" #-}
86012 -> ErrorPatchNovalue
{-# LINE 145 "src/Database/EJDB2/Result.hsc" #-}
86013 -> ErrorPatchTargetInvalid
{-# LINE 146 "src/Database/EJDB2/Result.hsc" #-}
86014 -> ErrorPatchInvalidValue
{-# LINE 147 "src/Database/EJDB2/Result.hsc" #-}
86015 -> ErrorPatchInvalidArrayIndex
{-# LINE 148 "src/Database/EJDB2/Result.hsc" #-}
86016 -> ErrorNotAnObject
{-# LINE 149 "src/Database/EJDB2/Result.hsc" #-}
86018 -> ErrorPatchTestFailed
{-# LINE 150 "src/Database/EJDB2/Result.hsc" #-}
85001 -> ErrorInvalidCollectionName
{-# LINE 151 "src/Database/EJDB2/Result.hsc" #-}
85002 -> ErrorInvalidCollectionMeta
{-# LINE 152 "src/Database/EJDB2/Result.hsc" #-}
85003 -> ErrorInvalidCollectionIndexMeta
{-# LINE 153 "src/Database/EJDB2/Result.hsc" #-}
85004 -> ErrorInvalidIndexMode
{-# LINE 154 "src/Database/EJDB2/Result.hsc" #-}
85005 -> ErrorMismatchedIndexUniquenessMode
{-# LINE 155 "src/Database/EJDB2/Result.hsc" #-}
85006 -> ErrorUniqueIndexConstraintViolated
{-# LINE 156 "src/Database/EJDB2/Result.hsc" #-}
85007 -> ErrorCollectionNotFound
{-# LINE 157 "src/Database/EJDB2/Result.hsc" #-}
85008 -> ErrorTargetCollectionExists
{-# LINE 158 "src/Database/EJDB2/Result.hsc" #-}
85009 -> ErrorPatchJsonNotObject
{-# LINE 159 "src/Database/EJDB2/Result.hsc" #-}
87001 -> ErrorQueryParse
{-# LINE 160 "src/Database/EJDB2/Result.hsc" #-}
87002 -> ErrorInvalidPlaceholder
{-# LINE 161 "src/Database/EJDB2/Result.hsc" #-}
87003 -> ErrorUnsetPlaceholder
{-# LINE 162 "src/Database/EJDB2/Result.hsc" #-}
87004 -> ErrorRegexpInvalid
{-# LINE 163 "src/Database/EJDB2/Result.hsc" #-}
87005 -> ErrorRegexpCharset
{-# LINE 164 "src/Database/EJDB2/Result.hsc" #-}
87006 -> ErrorRegexpSubexp
{-# LINE 165 "src/Database/EJDB2/Result.hsc" #-}
87007 -> ErrorRegexpSubmatch
{-# LINE 166 "src/Database/EJDB2/Result.hsc" #-}
87008 -> ErrorRegexpEngine
{-# LINE 167 "src/Database/EJDB2/Result.hsc" #-}
87009 -> ErrorSkipAlreadySet
{-# LINE 168 "src/Database/EJDB2/Result.hsc" #-}
87010 -> ErrorLimitAlreadySet
{-# LINE 169 "src/Database/EJDB2/Result.hsc" #-}
87011 -> ErrorOrderbyMaxLimit
{-# LINE 170 "src/Database/EJDB2/Result.hsc" #-}
87012 -> ErrorNoCollection
{-# LINE 171 "src/Database/EJDB2/Result.hsc" #-}
87013 -> ErrorInvalidPlaceholderValueType
{-# LINE 172 "src/Database/EJDB2/Result.hsc" #-}
_ -> error $ "Database.EJDB2.Bindings.IW.decodeRC " ++ show rc