aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prl/executor.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-05-27 23:24:12 +0000
committerGitHub <noreply@github.com>2026-05-27 23:24:12 +0000
commit9dc0391443ca16bf1ab3114d002aad83872f8a73 (patch)
treee4f78a2533e5e633b733c1ea21d0159aeca79b75 /lib/prl/executor.ml
parentf9097a0562ea8b40d40a19059578a9280b945de4 (diff)
downloadSakura-9dc0391443ca16bf1ab3114d002aad83872f8a73.tar.gz
Sakura-9dc0391443ca16bf1ab3114d002aad83872f8a73.zip
Improve the error handling situation (#71)
* Sketches of a condition system * `Condition.condition` -> `Condition.t` * Migrate `NT` over * Migrate `Branch` over * Migrate `Sublanguage` et al. over * Migrate the PRL over * Migrate the DRL over * Migrate the DML over * Have `Qualified_name.try_parse` return a `Condition.t` * Migrate the DDL over * Migrate the VCL over * Migrate the SCL over * Migrate the ICL over * Migrate the parsers over * Just inherit the errors from NT and the sublanguages * Migrate `Management.Physical` over * Migrate `Configuration` over * Migrate `Management.Branch` over * Migrate `Transport` over * Migrate `System` over * Migrate `Server` over * Include messages on on all conditions * A prettier stringifier
Diffstat (limited to '')
-rw-r--r--lib/prl/executor.ml34
1 files changed, 13 insertions, 21 deletions
diff --git a/lib/prl/executor.ml b/lib/prl/executor.ml
index 0ccaf22..fcd4ec0 100644
--- a/lib/prl/executor.ml
+++ b/lib/prl/executor.ml
@@ -1,22 +1,14 @@
module Make (NT : Nt.S) = struct
- type error =
- | ParseError of string
- | RuntimeError of string
- | NtError of Nt.error
- | UnknownPluginSymbol of string
- | RelationNotFound of string
-
- let sexp_of_error e =
- let open Sexplib.Sexp in
- match e with
- | ParseError s -> List [ Atom "parse-error"; Atom s ]
- | RuntimeError s -> List [ Atom "runtime-error"; Atom s ]
- | NtError e -> List [ Atom "nt-error"; Atom (Nt.string_of_error e) ]
- | UnknownPluginSymbol s -> List [ Atom "unknown-plugin-symbol"; Atom s ]
- | RelationNotFound s -> List [ Atom "relation-not-found"; Atom s ]
+ module Error = struct
+ open Condition
+ (* TODO: more structure *)
+ let parse_error msg = condition "parse-error" msg empty
+ let runtime_error msg = condition "runtime-error" msg empty
+ let unknown_plugin_symbol name = condition "unknown-plugin-symbol" "Unknown plugin" ("name" |=| (of_string name))
+ let relation_not_found name = condition "relation-not-found" "Relation not found" ("name" |=| (of_string name))
+ end
let ( let* ) = Result.bind
- let _map_nt r = Result.map_error (fun e -> NtError e) r
(* TODO: PRL function predicates are OCaml shared-library callbacks that
produce tuples at runtime. To make their output joinable inside the
@@ -26,17 +18,17 @@ module Make (NT : Nt.S) = struct
yet exist. Disable PRL execution until that bridge is in place. *)
let execute (_ctx : Sublanguage_context.t) (_stmt : Ast.statement) :
- (Sublanguage_types.result, error) result =
- Error (RuntimeError
+ (Sublanguage_types.result, Condition.t) result =
+ Error (Error.runtime_error
"PRL execution is temporarily disabled pending VM callback-cursor support")
let _execute_load_library _ctx _path =
- Error (RuntimeError "PRL disabled")
+ Error (Error.runtime_error "PRL disabled")
let _execute_define_function_predicate _ctx (_spec : Ast.function_predicate) =
let* _ = Ok () in
- Error (RuntimeError "PRL disabled")
+ Error (Error.runtime_error "PRL disabled")
let _execute_list_function_predicates _ctx =
- Error (RuntimeError "PRL disabled")
+ Error (Error.runtime_error "PRL disabled")
end