Skip to content

Commit

Permalink
better errors for everything
Browse files Browse the repository at this point in the history
  • Loading branch information
benbellick committed Dec 17, 2024
1 parent fb529c4 commit 78223f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/decoders_deriver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,17 @@ let rec expr_of_typ (typ : core_type)
Location.raise_errorf ~loc
"Cannot construct decoder for %s: cannot decode wildcard in type "
(string_of_core_type typ)
| _ ->
Location.raise_errorf ~loc "Cannot construct decoder for %s"
| { ptyp_desc = Ptyp_alias _; _ } ->
Location.raise_errorf ~loc
"Cannot construct decoder for %s: cannot decode type alias"
(string_of_core_type typ)
| { ptyp_desc = Ptyp_variant _; _ } ->
Location.raise_errorf ~loc
"Cannot construct decoder for %s: cannot decode polymorphic variant"
(string_of_core_type typ)
| { ptyp_desc = Ptyp_extension _; _ } ->
Location.raise_errorf ~loc
"Cannot construct decoder for %s: cannot decode type extension point"
(string_of_core_type typ)

and expr_of_tuple ~loc ~substitutions ?lift typs =
Expand Down
15 changes: 12 additions & 3 deletions src/encoders_deriver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,21 @@ let rec expr_of_typ (typ : core_type) : expression =
"Cannot construct encoder for %s: cannot encode explicitly polymorphic \
types"
(string_of_core_type typ)
| { ptyp_desc = Ptyp_any _; _ } ->
| { ptyp_desc = Ptyp_any; _ } ->
Location.raise_errorf ~loc
"Cannot construct encoder for %s: cannot encode wildcard in type "
(string_of_core_type typ)
| _ ->
Location.raise_errorf ~loc "Cannot construct encoder for %s"
| { ptyp_desc = Ptyp_alias _; _ } ->
Location.raise_errorf ~loc
"Cannot construct encoder for %s: cannot encode type alias"
(string_of_core_type typ)
| { ptyp_desc = Ptyp_variant _; _ } ->
Location.raise_errorf ~loc
"Cannot construct encoder for %s: cannot encode polymorphic variant"
(string_of_core_type typ)
| { ptyp_desc = Ptyp_extension _; _ } ->
Location.raise_errorf ~loc
"Cannot construct encoder for %s: cannot encode type extension point"
(string_of_core_type typ)

and expr_of_tuple ~loc (* ~substitutions ?lift *) typs =
Expand Down

0 comments on commit 78223f9

Please sign in to comment.