summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2023-02-16 00:28:19 -0500
committerRobby Zambito <contact@robbyzambito.me>2023-02-16 00:28:19 -0500
commitdd15498fdd81f1b60dab8545453e9c512496c921 (patch)
treeca83e62aa8ec364b2f13bf73f579ac76549c7521
parentcd7057a886b0ddb2a6c804bd297d07c739456b48 (diff)
Raise an error when trying to serialize a json record and a key is missing.
-rw-r--r--lib/zambyte/meta/json.sld5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/zambyte/meta/json.sld b/lib/zambyte/meta/json.sld
index 6d18d88..f305319 100644
--- a/lib/zambyte/meta/json.sld
+++ b/lib/zambyte/meta/json.sld
@@ -76,7 +76,10 @@
(define (from-json-string str)
(let ((json (string->json str)))
- (constructor (json-ref json 'fields) ...)))
+ (parameterize ((json-key-not-found
+ (lambda ()
+ (error "key not found in json string when converting to a record" 'from-json-string))))
+ (constructor (json-ref json 'fields) ...))))
(handle-field-declarations field-declarations) ...))))