From c253856d69e244fa57f8c149d9a7a5060e59f2f5 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 31 Dec 2015 11:39:36 -0800 Subject: [PATCH] improve error reporting in `validate-txexpr` --- main.rkt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.rkt b/main.rkt index cfc154e..97c28a3 100644 --- a/main.rkt +++ b/main.rkt @@ -140,7 +140,12 @@ [(txexpr? x) (and (validate-txexpr-attrs-with-context (get-attrs x)) (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)] - [else (error 'validate-txexpr (format "~v is not a list starting with a symbol" x))])) + [(and (list? x) (symbol? (car x))) + (and + (validate-txexpr-attrs-with-context (get-attrs x)) + (andmap (λ(e) (validate-txexpr-element-with-context e)) (get-elements x)) x)] + [(list? x) (error 'validate-txexpr (format "~v is a list but it doesn't start with a symbol" x))] + [else (error 'validate-txexpr (format "~v: not an X-expression" x))])) (define+provide+safe (txexpr tag [attrs null] [elements null])