diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2026-04-20 21:55:07 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-20 21:55:07 -0300 |
| commit | fdc63e730f91a4605ed4ff96a908e1f5e822d1bb (patch) | |
| tree | 36b0a66b81fc201a426171e190975289640cd579 /lib/error.ml | |
| parent | d3708bb28adcd0220142f1890ab96bfd2df637d3 (diff) | |
| download | Sakura-fdc63e730f91a4605ed4ff96a908e1f5e822d1bb.tar.gz Sakura-fdc63e730f91a4605ed4ff96a908e1f5e822d1bb.zip | |
New Server & Manipulation refactor
Co-authored-by: Estevan Castilho <tevo@riajuu.net>
Diffstat (limited to '')
| -rw-r--r-- | lib/error.ml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/error.ml b/lib/error.ml new file mode 100644 index 0000000..edaa85b --- /dev/null +++ b/lib/error.ml @@ -0,0 +1,34 @@ + +(** Error types for manipulation operations *) +type t = + | RelationNotFound of string + | RelationAlreadyExists of string + | TupleNotFound of Conventions.Hash.t + | DuplicateTuple of Conventions.Hash.t + | ConstraintViolation of string + | StorageError of string + | UnrecognizedSublanguage of string + | MalformedExpression of Sexplib.Sexp.t + (* TODO: think of a better way to manage and serialize sublanguage errors *) + | SublanguageError of Sexplib.Sexp.t + | Conflict of { old_db : Management.Database.t; new_db : Management.Database.t} + | SyntaxError of string + +let sexp_of_error e = + let open Sexplib.Sexp in + let error e ps = List (Atom e :: ps) in + let (<+>) key value = List [Atom key; value] in + match e with + (* TODO: think of a subset of common attributes that every error should have (message, etc)? *) + | RelationNotFound s -> error "relation-not-found" ["relation" <+> (Atom s)] + | RelationAlreadyExists s -> error "relation-already-exists" ["relation" <+> (Atom s)] + | TupleNotFound h -> error "tuple-not-found" ["hash" <+> (Atom h)] + | DuplicateTuple h -> error "duplicate-tuple" ["hash" <+> (Atom h)] + | ConstraintViolation s -> error "constraint-violation" ["message" <+> (Atom s)] + | StorageError s -> error "storage-error" ["message" <+> (Atom s)] + | UnrecognizedSublanguage s -> error "unrecognized-sublanguage" ["tag" <+> (Atom s)] + | MalformedExpression s -> error "malformed-expression" ["expression" <+> s] + | SublanguageError s -> error "sublanguage-error" ["error" <+> s] + | SyntaxError s -> error "syntax-error" ["message" <+> (Atom s)] + | Conflict { old_db; new_db } -> error "conflict" ["old-hash" <+> (Atom old_db.hash); + "new-hash" <+> (Atom new_db.hash)] |
