on dc3ee07 help sign in
143 lines 8.7 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 | FunctionNameInUseError AtomFunctionName
66 | FunctionNameNotInUseError AtomFunctionName
67 | EmptyCommitError
68 | FunctionArgumentCountMismatchError Int Int
69 | ConstructedAtomArgumentCountMismatchError Int Int
70 | NoSuchDataConstructorError DataConstructorName
71 | NoSuchTypeConstructorError TypeConstructorName
72 | InvalidAtomTypeName AtomTypeName
73 | AtomTypeNotSupported AttributeName --used by persistent driver
74 | AtomOperatorNotSupported T.Text --used by persistent driver
75 | EmptyTuplesError -- used by persistent driver
76 | AtomTypeCountError [AtomType] [AtomType]
77 | AtomFunctionTypeError AtomFunctionName Int AtomType AtomType --arg number
78 | AtomFunctionUserError AtomFunctionError
79 | PrecompiledFunctionRemoveError AtomFunctionName -- pre-compiled atom functions cannot be serialized, so they cannot change over time- they are referred to in perpetuity
80 | RelationValuedAttributesNotSupportedError [AttributeName]
81 | NotificationNameInUseError NotificationName
82 | NotificationNameNotInUseError NotificationName
83 | ImportError T.Text -- really? This should be broken out into some other error type- this has nothing to do with relational algebra
84 | ExportError T.Text
85 | UnhandledExceptionError String
86 | MergeTransactionError MergeError
87 | ScriptError ScriptCompilationError
88 | DatabaseContextFunctionUserError DatabaseContextFunctionError
89 | DatabaseLoadError PersistenceError
91 | SubschemaNameInUseError SchemaName
92 | SubschemaNameNotInUseError SchemaName
94 | SchemaCreationError SchemaError
96 | ImproperDatabaseStateError
98 | MultipleErrors [RelationalError]
99 deriving (Show,Eq,Generic,Binary,Typeable, NFData)
101data PersistenceError = InvalidDirectoryError FilePath |
102 MissingTransactionError TransactionId |
103 WrongDatabaseFormatVersionError String String
104 deriving (Show, Eq, Generic, Binary, NFData)
106--collapse list of errors into normal error- if there is just one, just return one
107someErrors :: [RelationalError] -> RelationalError
108someErrors [] = error "no errors in error list: function misuse"
109someErrors errList = if length errList == 1 then
110 head errList
111 else
112 MultipleErrors errList
114data MergeError = SelectedHeadMismatchMergeError |
115 PreferredHeadMissingMergeError HeadName |
116 StrategyViolatesConstraintMergeError |
117 InvalidMergeStrategyError MergeStrategy | -- this is an internal coding error
118 DisconnectedTransactionNotAMergeHeadError TransactionId |
119 StrategyViolatesComponentMergeError | --failed merge in inc deps, relvars, etc.
120 StrategyViolatesRelationVariableMergeError |
121 StrategyViolatesTypeConstructorMergeError
122 deriving (Show, Eq, Generic, Binary, Typeable)
124instance NFData MergeError where rnf = genericRnf
126data ScriptCompilationError = TypeCheckCompilationError String String | --expected, got
127 SyntaxErrorCompilationError String |
128 ScriptCompilationDisabledError |
129 OtherScriptCompilationError String
130 deriving (Show, Eq, Generic, Binary, Typeable, NFData)
132instance Exception ScriptCompilationError
134data SchemaError = RelVarReferencesMissing (S.Set RelVarName) |
135 RelVarInReferencedMoreThanOnce RelVarName |
136 RelVarOutReferencedMoreThanOnce RelVarName
137 deriving (Show, Eq, Generic, Binary, Typeable, NFData)
140-- errors returned from the distributed-process call handlers
141data ServerError = RequestTimeoutError |
142 ProcessDiedError String
143 deriving (Generic, Binary, Eq)