Prateek Jain
Prateek Jain

Reputation: 1552

How to make promise fail with an error in clojure?

I am trying to learn about Promise in clojure. From the docs, I can see we can create promise using promise function:

(def p (promise))

and we can resolve it using deliver function like this

(deliver p 42)

I want to understand, how can we reject a promise with error or exception. I've tried docs but it doesn't seems to help. I am new to functional programming and wondering there could be a different way for failed promises.

Upvotes: 3

Views: 253

Answers (1)

Neha Rastogi
Neha Rastogi

Reputation: 7

You can use fail function to reject a promise.

Please refer to this link for more details.

Upvotes: -1

Related Questions