aboutsummaryrefslogtreecommitdiff
path: root/src/gleam_stdlib.mjs
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2022-01-14 22:42:56 +0000
committerLouis Pilfold <louis@lpil.uk>2022-01-14 22:42:56 +0000
commit476195211e99133c7ef0fedf5a0d8ad3d0de5ede (patch)
tree570e50eb3d37833c8c49af6e69ee1c8fd6ac7a79 /src/gleam_stdlib.mjs
parent09e64691040430c4e73f587518db2658ec96a2e7 (diff)
downloadgleam_stdlib-476195211e99133c7ef0fedf5a0d8ad3d0de5ede.tar.gz
gleam_stdlib-476195211e99133c7ef0fedf5a0d8ad3d0de5ede.zip
Fix field error
Diffstat (limited to 'src/gleam_stdlib.mjs')
-rw-r--r--src/gleam_stdlib.mjs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/gleam_stdlib.mjs b/src/gleam_stdlib.mjs
index dd25832..6921348 100644
--- a/src/gleam_stdlib.mjs
+++ b/src/gleam_stdlib.mjs
@@ -494,10 +494,12 @@ export function classify_dynamic(data) {
}
function decoder_error(expected, got) {
+ return decoder_error_no_classify(expected, classify_dynamic(got));
+}
+
+function decoder_error_no_classify(expected, got) {
return new Error(
- List.fromArray([
- new DecodeError(expected, classify_dynamic(got), List.fromArray([])),
- ])
+ List.fromArray([new DecodeError(expected, got, List.fromArray([]))])
);
}
@@ -560,7 +562,7 @@ export function decode_option(data, decoder) {
}
export function decode_field(value, name) {
- let error = () => decoder_error("object", value);
+ let error = () => decoder_error_no_classify("field", "nothing");
if (value instanceof Map) {
let entry = value.get(name);
return entry.isOk() ? entry : error();