From 9169ec543e7c6958c8a9ded820eb86a949ea7a7f Mon Sep 17 00:00:00 2001 From: Javier Chavarri Date: Sun, 15 Dec 2024 15:36:49 +0000 Subject: [PATCH] remove refs to `DecodeError` --- README.md | 2 +- src/Json.mli | 2 +- src/__tests__/Json_decode_test.ml | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index ae146ff..6c781b0 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Based on [@glennsl/bs-json](https://github.com/glennsl/bs-json). The Decode module in particular provides a basic set of decoder functions to be composed into more complex decoders. A decoder is a function that takes a `Js.Json.t` and either returns a value of the desired type if successful or -raises a `DecodeError` exception if not. Other functions accept a decoder and +raises an `Of_json_error` exception if not. Other functions accept a decoder and produce another decoder. Like `array`, which when given a decoder for type `t` will return a decoder that tries to produce a value of type `t array`. So to decode an `int array` you combine `Json.Decode.int` with `Json.Decode.array` diff --git a/src/Json.mli b/src/Json.mli index 820f002..a0c013b 100644 --- a/src/Json.mli +++ b/src/Json.mli @@ -141,7 +141,7 @@ val of_json : json of_json module Of_json : sig (** Provides a set of low level combinator primitives to decode Js.Json.t data structures A decoder combinator will return the - decoded value if successful, or raise a [DecodeError of string] if + decoded value if successful, or raise a [Of_json_error] exception if unsuccessful, where the string argument contains the error message. Decoders are designed to be combined to produce more complex decoders that can decode arbitrary data structures, though the diff --git a/src/__tests__/Json_decode_test.ml b/src/__tests__/Json_decode_test.ml index a198e3d..268ddb4 100644 --- a/src/__tests__/Json_decode_test.ml +++ b/src/__tests__/Json_decode_test.ml @@ -211,7 +211,7 @@ let () = (Json_error "Expected boolean, got 1\n\tin array at index 0") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : _ array) = @@ -258,7 +258,7 @@ let () = (Json_error "Expected boolean, got 1\n\tin array at index 0") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : 'a list) = @@ -334,7 +334,7 @@ let () = with | Of_json_error (Json_error "Expected array as tuple, got 4") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : int * int) = @@ -406,7 +406,7 @@ let () = with | Of_json_error (Json_error "Expected array as tuple, got 4") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : 'a * int) = @@ -481,7 +481,7 @@ let () = with | Of_json_error (Json_error "Expected array as tuple, got 4") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : int * int * int) = @@ -558,7 +558,7 @@ let () = with | Of_json_error (Json_error "Expected array as tuple, got 4") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : int * int * int * int) = @@ -606,7 +606,7 @@ let () = "Expected string, got null\n\tin object at key 'a'") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : _ Js.Dict.t) = @@ -662,7 +662,7 @@ let () = -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let _ = @@ -808,7 +808,7 @@ let () = fail "should throw" with Of_json_error (Json_error "Expected field 'y'") -> pass); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : 'a option) = @@ -828,7 +828,7 @@ let () = expect @@ (oneOf [ int; field "x" int ]) (Encode.int 23) |> toEqual 23); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let _ = (oneOf [ (fun _ -> raise Foo) ]) Encode.null in @@ -874,7 +874,7 @@ let () = test "object" (fun () -> expect @@ (withDefault 0 int) (Encode.object_ []) |> toEqual 0); - test "non-DecodeError exceptions in decoder should pass through" + test "non-Of_json_error exceptions in decoder should pass through" (fun () -> try let (_ : int) =