Skip to content

Commit 4d2d6b3

Browse files
authored
Merge pull request #40 from reynir/Mirage_kv.Key.add-invalid_arg
Mirage_kv.Key.add raises invalid_argument, docs
2 parents b01b94a + fc6d071 commit 4d2d6b3

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

mirage-kv.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ depends: [
2020
"lwt" {>= "4.0.0"}
2121
"optint" {>= "0.2.0"}
2222
"ptime" {>= "1.0.0"}
23-
"alcotest" {with-test}
23+
"alcotest" {with-test & >= "0.8.1"}
2424
]
2525
synopsis: "MirageOS signatures for key/value devices"
2626
description: """

src/mirage_kv.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Key = struct
2222
(* Store the path as a reverse list to optimise basename and (/)
2323
operations *)
2424

25-
let err_invalid_segment x = Fmt.failwith "%S is not a valid segment" x
25+
let err_invalid_segment x = Fmt.kstr invalid_arg "%S is not a valid segment" x
2626

2727
let check_segment x =
2828
String.iter (function '/' -> err_invalid_segment x | _ -> ()) x;

src/mirage_kv.mli

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ module Key: sig
4343
equal. *)
4444

4545
val add : t -> string -> t
46-
(** [add t s] is the concatenated key [t/s]. Raise
47-
[Invalid_argument] if [s] contains ["/"]. *)
46+
(** [add t s] is the concatenated key [t/s].
47+
48+
@raise Invalid_argument if [s] contains ['/']. *)
4849

4950
val ( / ) : t -> string -> t
50-
(** [t / x] is [add t x]. *)
51+
(** [t / x] is [add t x].
52+
53+
@raise Invalid_argument if [s] contains ['/']. *)
5154

5255
val append : t -> t -> t
5356
(** [append x y] is the concatenated key [x/y]. *)

test/test.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ let path_add () =
2222
try
2323
let _ = Key.(v p / b) in
2424
Alcotest.failf "%s is not a valid segment, should fail" b
25-
with Failure _ -> ()
25+
with Invalid_argument _ -> ()
2626
in
2727
check "" "bar" "/bar";
2828
check "/" "foo" "/foo";

0 commit comments

Comments
 (0)