Skip to content

Commit

Permalink
remove refs to DecodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Dec 15, 2024
1 parent 4bfb448 commit 9169ec5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/Json.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 11 additions & 11 deletions src/__tests__/Json_decode_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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) =
Expand Down Expand Up @@ -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 _ =
Expand Down Expand Up @@ -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) =
Expand All @@ -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
Expand Down Expand Up @@ -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) =
Expand Down

0 comments on commit 9169ec5

Please sign in to comment.