diff options
author | Arun Isaac | 2025-08-17 03:25:43 +0100 |
---|---|---|
committer | Arun Isaac | 2025-08-17 13:11:47 +0100 |
commit | 8044c5646e7b426a2b6362efdb9d33efd5fb5ff7 (patch) | |
tree | 868d68f6f886ab3c03dc750a76d90432a69c5e99 | |
parent | ee6bde50a4a68d4f7d8a8b0bbc6e89ae7899fec9 (diff) | |
download | ravanan-8044c5646e7b426a2b6362efdb9d33efd5fb5ff7.tar.gz ravanan-8044c5646e7b426a2b6362efdb9d33efd5fb5ff7.tar.lz ravanan-8044c5646e7b426a2b6362efdb9d33efd5fb5ff7.zip |
reader: Capture and report exceptions in read-inputs.
-rw-r--r-- | ravanan/reader.scm | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/ravanan/reader.scm b/ravanan/reader.scm index 3a2ba10..46047d3 100644 --- a/ravanan/reader.scm +++ b/ravanan/reader.scm @@ -292,19 +292,27 @@ array of array of @code{File}s, etc. Else, return @code{#f}" (define (read-inputs inputs-file) "Read @var{inputs-file} resolving file paths if any." - (call-with-current-directory (dirname inputs-file) - (lambda () - (map (match-lambda - ((input-id . input) - (cons input-id - (normalize-input input)))) - ;; Even though YAML is a superset of JSON, use the JSON - ;; reader if possible; it is simpler and less prone to type - ;; ambiguities. - (if (string=? (file-name-extension inputs-file) - ".json") - (read-json-file (basename inputs-file)) - (read-yaml-file (basename inputs-file))))))) + (guard (c ((and (who-condition? c) + (memq (condition-who c) + '(read-json-file read-yaml-file)) + (irritants-condition? c)) + (user-error "Unable to read inputs file ~a: ~a" + inputs-file + (string-join (condition-irritants c) + ": ")))) + (call-with-current-directory (dirname inputs-file) + (lambda () + (map (match-lambda + ((input-id . input) + (cons input-id + (normalize-input input)))) + ;; Even though YAML is a superset of JSON, use the JSON + ;; reader if possible; it is simpler and less prone to type + ;; ambiguities. + (if (string=? (file-name-extension inputs-file) + ".json") + (read-json-file (basename inputs-file)) + (read-yaml-file (basename inputs-file)))))))) (define (coerce-type val type) "Coerce @var{val} to @var{type}." |