on 52182bc help sign in
145 lines 8.8 kB history raw
1{-# LANGUAGE DeriveGeneric, DeriveAnyClass #-}
2module ProjectM36.Error where
3import ProjectM36.Base
4import ProjectM36.DatabaseContextFunctionError
5import ProjectM36.AtomFunctionError
6import qualified Data.Set as S
7import Control.DeepSeq (NFData, rnf)
8import Control.DeepSeq.Generics (genericRnf)
9import GHC.Generics (Generic)
10import qualified Data.Text as T
11import Data.Binary
12import Data.Typeable
13import Control.Exception
15data RelationalError = NoSuchAttributeNamesError (S.Set AttributeName)
16 | TupleAttributeCountMismatchError Int --attribute name
17 | EmptyAttributesError
18 | DuplicateAttributeNamesError (S.Set AttributeName)
19 | TupleAttributeTypeMismatchError Attributes
20 | AttributeCountMismatchError Int
21 | AttributeNamesMismatchError (S.Set AttributeName)
22 | AttributeNameInUseError AttributeName
23 | AttributeIsNotRelationValuedError AttributeName
24 | CouldNotInferAttributes
25 | RelVarNotDefinedError RelVarName
26 | RelVarAlreadyDefinedError RelVarName
27 | RelationTypeMismatchError Attributes Attributes --expected, found
28 | InclusionDependencyCheckError IncDepName
29 | InclusionDependencyNameInUseError IncDepName
30 | InclusionDependencyNameNotInUseError IncDepName
31 | ParseError T.Text
32 | PredicateExpressionError T.Text
33 | NoCommonTransactionAncestorError TransactionId TransactionId
34 | NoSuchTransactionError TransactionId
35 | RootTransactionTraversalError
36 | HeadNameSwitchingHeadProhibitedError HeadName
37 | NoSuchHeadNameError HeadName
38 | UnknownHeadError
39 | NewTransactionMayNotHaveChildrenError TransactionId
40 | ParentCountTraversalError Int Int --maximum, requested
41 | NewTransactionMissingParentError TransactionId
42 | TransactionIsNotAHeadError TransactionId
43 | TransactionGraphCycleError TransactionId
44 | SessionIdInUseError TransactionId
45 | NoSuchSessionError TransactionId
46 | FailedToFindTransactionError TransactionId
47 | TransactionIdInUseError TransactionId
48 | NoSuchFunctionError AtomFunctionName
49 | NoSuchTypeConstructorName TypeConstructorName
50 | TypeConstructorAtomTypeMismatch TypeConstructorName AtomType
51 | AtomTypeMismatchError AtomType AtomType
52 | TypeConstructorNameMismatch TypeConstructorName TypeConstructorName
53 | AtomTypeTypeConstructorReconciliationError AtomType TypeConstructorName
54 | DataConstructorNameInUseError DataConstructorName
55 | DataConstructorUsesUndeclaredTypeVariable TypeVarName
56 | TypeConstructorTypeVarsMismatch (S.Set TypeVarName) (S.Set TypeVarName)
57 | TypeConstructorTypeVarMissing TypeVarName
58 | TypeConstructorTypeVarsTypesMismatch TypeConstructorName TypeVarMap TypeVarMap
59 | DataConstructorTypeVarsMismatch DataConstructorName TypeVarMap TypeVarMap
60 | AtomFunctionTypeVariableResolutionError AtomFunctionName TypeVarName
61 | AtomFunctionTypeVariableMismatch TypeVarName AtomType AtomType
62 | AtomTypeNameInUseError AtomTypeName
63 | IncompletelyDefinedAtomTypeWithConstructorError
64 | AtomTypeNameNotInUseError AtomTypeName
65 | AttributeNotSortableError Attribute
66 | FunctionNameInUseError AtomFunctionName
67 | FunctionNameNotInUseError AtomFunctionName
68 | EmptyCommitError
69 | FunctionArgumentCountMismatchError Int Int
70 | ConstructedAtomArgumentCountMismatchError Int Int
71 | NoSuchDataConstructorError DataConstructorName
72 | NoSuchTypeConstructorError TypeConstructorName
73 | InvalidAtomTypeName AtomTypeName
74 | AtomTypeNotSupported AttributeName --used by persistent driver
75 | AtomOperatorNotSupported T.Text --used by persistent driver
76 | EmptyTuplesError -- used by persistent driver
77 | AtomTypeCountError [AtomType] [AtomType]
78 | AtomFunctionTypeError AtomFunctionName Int AtomType AtomType --arg number
79 | AtomFunctionUserError AtomFunctionError
80 | PrecompiledFunctionRemoveError AtomFunctionName -- pre-compiled atom functions cannot be serialized, so they cannot change over time- they are referred to in perpetuity
81 | RelationValuedAttributesNotSupportedError [AttributeName]
82 | NotificationNameInUseError NotificationName
83 | NotificationNameNotInUseError NotificationName
84 | ImportError T.Text -- really? This should be broken out into some other error type- this has nothing to do with relational algebra
85 | ExportError T.Text
86 | UnhandledExceptionError String
87 | MergeTransactionError MergeError
88 | ScriptError ScriptCompilationError
89 | LoadFunctionError
90 | DatabaseContextFunctionUserError DatabaseContextFunctionError
91 | DatabaseLoadError PersistenceError
93 | SubschemaNameInUseError SchemaName
94 | SubschemaNameNotInUseError SchemaName
96 | SchemaCreationError SchemaError
98 | ImproperDatabaseStateError
100 | MultipleErrors [RelationalError]
101 deriving (Show,Eq,Generic,Binary,Typeable, NFData)
103data PersistenceError = InvalidDirectoryError FilePath |
104 MissingTransactionError TransactionId |
105 WrongDatabaseFormatVersionError String String
106 deriving (Show, Eq, Generic, Binary, NFData)
108--collapse list of errors into normal error- if there is just one, just return one
109someErrors :: [RelationalError] -> RelationalError
110someErrors [] = error "no errors in error list: function misuse"
111someErrors errList = if length errList == 1 then
112 head errList
113 else
114 MultipleErrors errList
116data MergeError = SelectedHeadMismatchMergeError |
117 PreferredHeadMissingMergeError HeadName |
118 StrategyViolatesConstraintMergeError |
119 InvalidMergeStrategyError MergeStrategy | -- this is an internal coding error
120 DisconnectedTransactionNotAMergeHeadError TransactionId |
121 StrategyViolatesComponentMergeError | --failed merge in inc deps, relvars, etc.
122 StrategyViolatesRelationVariableMergeError |
123 StrategyViolatesTypeConstructorMergeError
124 deriving (Show, Eq, Generic, Binary, Typeable)
126instance NFData MergeError where rnf = genericRnf
128data ScriptCompilationError = TypeCheckCompilationError String String | --expected, got
129 SyntaxErrorCompilationError String |
130 ScriptCompilationDisabledError |
131 OtherScriptCompilationError String
132 deriving (Show, Eq, Generic, Binary, Typeable, NFData)
134instance Exception ScriptCompilationError
136data SchemaError = RelVarReferencesMissing (S.Set RelVarName) |
137 RelVarInReferencedMoreThanOnce RelVarName |
138 RelVarOutReferencedMoreThanOnce RelVarName
139 deriving (Show, Eq, Generic, Binary, Typeable, NFData)
142-- errors returned from the distributed-process call handlers
143data ServerError = RequestTimeoutError |
144 ProcessDiedError String
145 deriving (Generic, Binary, Eq)