這是你怎麼能輕易複製超時:
(http/get "http://google.com" {:timeout 1}
(fn [{:keys [status headers body error]}] ;; asynchronous response handling
(if error
(do
(if (instance? org.httpkit.client.TimeoutException error)
(println "There was timeout")
(println "There wasn't timeout"))
(println "Failed, exception is " error))
(println "Async HTTP GET: " status))))
它將打印錯誤,是org.httpkit.client.TimeoutException
的實例
所以,你必須改變你的回調接受地圖。如果發生錯誤,該映射中的:error字段不爲零,如果發生超時,它將包含TimeoutException。順便說一句,這是從the client documentation只是稍微修改的例子 - 我認爲這是很好解釋在那裏。
所以試着改變你的回調:
(defn post-callback
[{:keys [status headers body error]}]
;; and check the error same way as I do above
)