Clojure JIRAhttp://dev.clojure.org/jira
This file is an XML representation of an issueen-us4.464925-07-2011[ASYNC-61] Exceptions thrown inside go/thread blocks propagate up and out of ThreadPoolExcecutorhttp://dev.clojure.org/jira/browse/ASYNC-61
core.async<p>If a go or thread blocks throws an exception, there is nothing in Clojure to catch and handle (or report) the exception. Instead, it propagates up to the ThreadExcecutor which invokes its NO-OP afterExecute() method and is re-thrown, ultimately being displayed on the System.err:</p>
<blockquote>
<p>Exception in thread "async-dispatch-32" java.lang.IllegalStateException: Fall down, go boom!<br/>
at flashiz.resources.orders$index.invoke(orders.clj:26)<br/>
at clojure.lang.Var.invoke(Var.java:411)<br/>
at clojure.lang.AFn.applyToHelper(AFn.java:159)<br/>
at clojure.lang.Var.applyTo(Var.java:532)<br/>
at clojure.core$apply.invoke(core.clj:617)<br/>
at io.aviso.rook$rook_dispatcher.invoke(rook.clj:225)<br/>
at flashiz.async$wrap_sync_handler$fn__9005.invoke(async.clj:34)<br/>
at flashiz.resources$authorize_async_rook_middleware$fn_<em>9356$fn</em><em>9402$state_machine</em><em>3245</em><em>auto</em>__<em>9403$fn</em>_9405.invoke(resources.clj:21)<br/>
at flashiz.resources$authorize_async_rook_middleware$fn_<em>9356$fn</em><em>9402$state_machine</em><em>3245</em><em>auto</em>___9403.invoke(resources.clj:21)<br/>
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:945)<br/>
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:949)<br/>
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__3261.invoke(ioc_macros.clj:958)<br/>
at clojure.core.async.impl.channels.ManyToManyChannel$fn__2256.invoke(channels.clj:80)<br/>
at clojure.lang.AFn.run(AFn.java:24)<br/>
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)<br/>
at java.lang.Thread.run(Thread.java:724)</p></blockquote>
<p>It would be nice if execution of the go/thread block was wrapped in an exception handler that delegated to a default function to report the exception. My goal is to be able to alter that function to report it more nicely and/or write it to a persistent log file.</p>core.async 0.1.267.0-0d7780-alpha on JDK 1.7
<br/>
ASYNC-61Exceptions thrown inside go/thread blocks propagate up and out of ThreadPoolExcecutorEnhancementMinorOpenUnresolvedUnassignedHoward Lewis ShipexceptionsMon, 24 Mar 2014 11:48:32 -0500Wed, 6 Aug 2014 10:30:11 -050022<p>Patches on <a href="http://dev.clojure.org/jira/browse/ASYNC-76" title="Exceptions cannot be captured by default uncaught exception handler"><del>ASYNC-76</del></a> have been applied and exceptions will now flow up to the top of the thread, where they can be caught by the standard Thread uncaught exception handler mechanism or ultimately by the default uncaught exception handler, which can be set for the application. There may still be further changes to support exception handling in thread/go.</p>Global Rank