aboutsummaryrefslogtreecommitdiffstats
path: root/lib/system.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-05-23 00:21:59 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-05-23 00:21:59 +0000
commiteafeb4955059732f2e5febe4991777df8b00d52a (patch)
tree2029285cc08fbd30a4f5e585a93a720587ec137e /lib/system.ml
parent98a77e781d970e6a0fc7a72a453d03495d732711 (diff)
downloadSakura-eafeb4955059732f2e5febe4991777df8b00d52a.tar.gz
Sakura-eafeb4955059732f2e5febe4991777df8b00d52a.zip
Migrate `System` over
Diffstat (limited to 'lib/system.ml')
-rw-r--r--lib/system.ml11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/system.ml b/lib/system.ml
index 716b6a8..831cf74 100644
--- a/lib/system.ml
+++ b/lib/system.ml
@@ -17,6 +17,13 @@ type registry = {
transport : transport_provider Utilities.StringMap.t;
}
+module Error = struct
+ open Condition
+ let unknown_backend component tag = condition "unknown-backend"
+ ("component" |=| (of_string component) &
+ "tag" |=| (of_string tag))
+end
+
let registry : registry =
let open Utilities.StringMap in
{
@@ -54,7 +61,7 @@ let assemble (config : Configuration.t) : (unit -> unit, Condition.t) result =
let* nt_provider =
Utilities.StringMap.find_opt nt_tag registry.nt
|> Option.to_result
- ~none:(Printf.sprintf "Unknown NT backend: %s" nt_tag)
+ ~none:(Error.unknown_backend "nt" nt_tag)
in
let* packed_nt = nt_provider nt_body in
let* transport_tag, transport_body =
@@ -66,7 +73,7 @@ let assemble (config : Configuration.t) : (unit -> unit, Condition.t) result =
let* transport_provider =
Utilities.StringMap.find_opt transport_tag registry.transport
|> Option.to_result
- ~none:(Printf.sprintf "Unknown transport backend: %s" transport_tag)
+ ~none:(Error.unknown_backend "transport" transport_tag)
in
let* packed_transport = transport_provider transport_body in
let (NtParcel (module NT)) = packed_nt in