From b2e3a9fd8b3c0c2a76684a78aaff80a759641120 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 16 Jan 2022 13:14:49 +0530 Subject: ccwl: Raise parameter errors in workflow steps as exceptions. * ccwl/ccwl.scm (collect-steps): Raise parameter errors in workflow steps as exceptions. --- ccwl/ccwl.scm | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/ccwl/ccwl.scm b/ccwl/ccwl.scm index 32022d7..f31e99a 100644 --- a/ccwl/ccwl.scm +++ b/ccwl/ccwl.scm @@ -479,30 +479,37 @@ represented by objects." (syntax->datum (pairify #'(args ...))))) (() #t) (missing-parameters - (scm-error 'misc-error - #f - "Step `~S' missing required parameters `~S'" - (list step-id missing-parameters) - #f))) + (raise-exception + ;; TODO: Report entire form, not just the name of the + ;; step. + (condition (ccwl-violation #'function) + (formatted-message "Step ~a missing required parameters ~a" + step-id + (map symbol->keyword missing-parameters)))))) ;; Test for unknown keys. (for-each (match-lambda ((arg . value) - (unless (memq (keyword->symbol arg) + (unless (memq (keyword->symbol (syntax->datum arg)) (function-input-keys function-object)) - (scm-error 'misc-error - #f - "ccwl command `~S' does not accept input key `~S'. Accepted keys are `~S'." - (list (syntax->datum #'ccwl-function) - arg - (function-input-keys function-object)) - #f)) - (unless (memq value input-key-symbols) - (scm-error 'misc-error - #f - "ccwl step `~S' supplied with unknown key `~S'. Known keys at this step are `~S'." - (list step-id value input-key-symbols) - #f)))) - (syntax->datum (pairify #'(args ...)))) + (raise-exception + ;; TODO: Report arg and value, not just arg. + (condition (ccwl-violation arg) + ;; TODO: Do not report accepted keys + ;; that have already been satisfied. + (formatted-message "Step ~a does not accept input key ~a. Accepted keys are ~a." + step-id + (syntax->datum arg) + (map symbol->keyword + (function-input-keys function-object)))))) + (unless (memq (syntax->datum value) + input-key-symbols) + (raise-exception + (condition (ccwl-violation value) + (formatted-message "Step ~a supplied with unknown key ~a. Known keys at this step are ~a." + step-id + (syntax->datum value) + input-key-symbols)))))) + (pairify #'(args ...))) (values (append (remove key-step input-keys) (map (lambda (output) (key (output-id output) step-id)) -- cgit v1.2.3