aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Handle.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/protocols/Handle.ml')
-rw-r--r--lib/protocols/Handle.ml9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/protocols/Handle.ml b/lib/protocols/Handle.ml
index 524386b..313a3d4 100644
--- a/lib/protocols/Handle.ml
+++ b/lib/protocols/Handle.ml
@@ -1,5 +1,12 @@
type protocol = ..
+module Error = struct
+ open Concepts.Condition
+
+ let unimplemented_protocol () = condition "unimplemented-protocol" "A required protocol was not implemented by the specified object"
+ empty
+end
+
class type obj = object
method reference : bool
method release : unit
@@ -45,3 +52,5 @@ let release ({ valid; _ } as handle) =
let o = object_of handle in
valid := false;
o#release
+
+let require f h = Option.to_result ~none:(Error.unimplemented_protocol ()) (f h)