overtone / at-at

Ahead-of-time function scheduler
Eclipse Public License 1.0
292 stars 38 forks source link

Expose exceptions in scheduled functions #7

Closed dmac closed 11 months ago

dmac commented 11 years ago

At the moment, if a scheduled function throws an exception it fails silently.

(def tp (at-at/mk-pool))

(defn -main [& args]
  (at-at/every 1000 #(throw (Exception. "You'll never see me"))
               tp :desc "My job")
  (Thread/sleep 3000)
  (System/exit 0))

This can be confusing and make it appear that the function isn't running.

Ideally I'd like to see output like this:

at-at task [1][RECUR] "My job" threw java.lang.Exception: You'll never see me
at-at task [1][RECUR] "My job" threw java.lang.Exception: You'll never see me
at-at task [1][RECUR] "My job" threw java.lang.Exception: You'll never see me

Another option would be to fail fast by re-raising the exception and crashing the program, which would at least indicate that the user needs to handle an error case.

philc commented 11 years ago

This would be a great usability win.

samaaron commented 11 years ago

Happy to consider pull requests.

philc commented 11 years ago

Bump. The pull request is in!

pesterhazy commented 10 years ago

IMO this a fairly important bug: a library should not swallow exceptions (even ArityExceptions for function calls) silently!

davidrupp commented 9 years ago

Bump.

adamneilson commented 9 years ago

Bump +1

mjg123 commented 8 years ago

AIUI any exception on a background thread will cause the thread to die silently - this isn't specific to at-at. There's an approach you can use here: https://stuartsierra.com/2015/05/27/clojure-uncaught-exceptions

kenfehling commented 7 years ago

@mjg123 I tried using the uncaught exception handler from that article but still no errors are getting through. Do you have an example of using it with at-at?