如果一个go或thread阻塞抛出异常,Clojure中没有东西可以捕获和处理(或报告)异常。相反,它会传播到ThreadExcecutor,调用它的NO-OP afterExecute()方法,然后重新抛出,最终显示在System.err上
{quote}
线程"async-dispatch-32"中的异常:java.lang.IllegalStateException: Fall down, go boom!
at flashiz.resources.orders$index.invoke(orders.clj:26)
at clojure.lang.Var.invoke(Var.java:411)
at clojure.lang.AFn.applyToHelper(AFn.java:159)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.core$apply.invoke(core.clj:617)
at io.aviso.rook$rook_dispatcher.invoke(rook.clj:225)
at flashiz.async$wrap_sync_handler$fn__9005.invoke(async.clj:34)
at flashiz.resources$authorize_async_rook_middleware$fn__9356$fn__9402$state_machine__3245__auto____9403$fn__9405.invoke(resources.clj:21)
at flashiz.resources$authorize_async_rook_middleware$fn__9356$fn__9402$state_machine__3245__auto____9403.invoke(resources.clj:21)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:945)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:949)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__3261.invoke(ioc_macros.clj:958)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__2256.invoke(channels.clj:80)
at clojure.lang.AFn.run(AFn.java:24)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
{quote}
如果要对go/thread块的执行进行异常处理,并将其委托给默认函数来报告异常,那将会很方便。我的目标是修改该函数以更优雅地报告它,并将其写入持久化日志文件。