这是你怎么能轻易复制超时:
(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
)