From ec92808ff4ea80fcad18a6d684247afe99fb76c1 Mon Sep 17 00:00:00 2001 From: Peter Taoussanis Date: Thu, 9 May 2024 15:25:22 +0200 Subject: [PATCH] [new] Add compile-time protection against accidental `:msg_` signal option --- src/taoensso/telemere/impl.cljc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/taoensso/telemere/impl.cljc b/src/taoensso/telemere/impl.cljc index 30159b7..8656f8c 100644 --- a/src/taoensso/telemere/impl.cljc +++ b/src/taoensso/telemere/impl.cljc @@ -625,13 +625,19 @@ :elide? :allow? #_:expansion-id))] ;; Compile-time validation - (when (and run-form error-form) - (throw ; Prevent ambiguity re: source of error - (ex-info "Signals cannot have both `:run` and `:error` opts at the same time" - {:run-form run-form - :error-form error-form - :location location - :other-opts (dissoc opts :run :error)}))) + (do + (when (and run-form error-form) ; Ambiguous source of error + (throw + (ex-info "Signals cannot have both `:run` and `:error` opts at the same time" + {:run-form run-form + :error-form error-form + :location location + :other-opts (dissoc opts :run :error)}))) + + (when-let [e (find opts :msg_)] ; Common typo/confusion + (throw + (ex-info "Signals cannot have `:msg_` opt (did you mean `:msg`?))" + {:msg_ (enc/typed-val (val e))})))) `(delay ;; Delay (cache) shared by all handlers. Covers signal `:let` eval, signal construction,