Is there any way to specify the error message when using set-
validator! with a dynamic var?

In a situation like this:

(binding [*my-var* -1]
  (foo))

I'd like to be able to throw a custom exception when they try to bind
to a negative number.

Using set-validator! like this, the Exception message is ignored:

(set-validator! #'*d* (fn [x] (if (< x 4) (throw (Exception. "*my-var*
can only be bound to a non-negative number")) true)))

Instead the message you see at the REPL is:
java.lang.IllegalStateException: Invalid reference state
(NO_SOURCE_FILE:0)

Is there a way to specify the error message on validation-error of a
dynamic var?

Thanks,
Alex

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to