Permalink
Browse files

(test) added demo function for async exception

Signed-off-by: Ning Sun <sunng@about.me>
  • Loading branch information...
sunng87 committed Jan 19, 2018
1 parent 38c9423 commit f4f136aaf78defc3db1c20d5765370e03f56daed
Showing with 14 additions and 0 deletions.
  1. +7 −0 examples/slacker/example/api.clj
  2. +7 −0 examples/slacker/example/client.clj
@@ -50,3 +50,10 @@
(d/success! defr "Deferred result.")))
(.start))
defr))
(defn async-exception []
(let [defr (d/deferred)]
(doto (Thread. #(do
(d/error! defr (RuntimeException. "Expected error in async fn."))))
(.start))
defr))
@@ -21,6 +21,7 @@
(defn-remote conn slacker.example.api/make-error)
(defn-remote conn slacker.example.api/return-nil)
(defn-remote conn slacker.example.api/async-result)
(defn-remote conn slacker.example.api/async-exception)
#_(defn-remote conn slacker.example.api/not-found)
(defn-remote conn2 slacker.example.api2/echo2)
@@ -52,6 +53,12 @@
(println "Calling server-side async function: "
(async-result))
(println "Calling a server-side async function that throws exception: ")
(try
(async-exception)
(catch Exception e
(println "Exception received: " (-> (ex-data e) :cause :exception))))
(println (echo2 "Echo me."))
(try
(make-error)

0 comments on commit f4f136a

Please sign in to comment.