Huh, I was sure I had done this before, but I misremembered, I was using my own promise that rethrew Throwable instances on deref (and it was in clojurescript!)
Clojure promises have no notion of failure, only realized/not-realized. You need to deliver a sentinel type or value and check for it on deref, or implement your own promise type which does it for you. (It's not that hard: https://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L6803 ) On Friday, August 7, 2015 at 4:09:39 PM UTC-5, William la Forge wrote: > > Sorry, I meant to ask how to fail with a promise? It seems that there is > no fail method. > > On Friday, August 7, 2015 at 4:52:47 PM UTC-4, Francis Avila wrote: >> >> Futures automatically capture exceptions raised in their bodies and >> reraise them when the future is derefed. Promises also throw exceptions >> when derefed. >> >> Unlike promises, futures are created with the code that delivers their >> value, so calling fail and deliver explicitly on a future makes no sense. >> >> Think of futures as a thin wrapper around a promise which spawns a >> thread, runs the code, and to the wrapped promise either delivers the >> result of the code or calls (fail private-promise raised-exception) for you. >> >> On Friday, August 7, 2015 at 2:14:30 PM UTC-5, William la Forge wrote: >>> >>> A future fails when it throws an exception. How to do that with a future? >>> >>> It looks like (fail future exception) does not do the trick: >>> http://dev.clojure.org/display/design/Promises >>> >>> -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.