If I try to use Slingshot like this: (defn- check-that-log-file-exists[] (if-not (fs/exists? "/var/log/humongorous") (slingshot/throw+ {:type :humongorous-api.supervisor/no-log-file :message "In start/check-that-log-file-exists, we could not find the log file /var/log/humongorous" })))
and this is called from (launch) which is called like this: (handle-error java.lang.Object #'start/launch) (defn start [] (dire/supervise #'start/launch)) The old rule with Slingshot is that if you wanted to catch everything you could catch Object, as the universal catch-all, but it is not working for me here. I end up with this in the logs: Starting the app #error { :cause clojure.lang.PersistentArrayMap cannot be cast to java.lang.Throwable :via [{:type java.lang.ClassCastException :message clojure.lang.PersistentArrayMap cannot be cast to java.lang.Throwable :at [clj_stacktrace.core$parse_exception invoke core.clj 120]}] :trace [[clj_stacktrace.core$parse_exception invoke core.clj 120] [humongorous_api.supervisor_start$fn__71 doInvoke supervisor_start.clj 16] [clojure.lang.RestFn invoke RestFn.java 410] [clojure.lang.AFn applyToHelper AFn.java 154] [clojure.lang.RestFn applyTo RestFn.java 132] [clojure.core$apply invoke core.clj 632] [dire.core$fn__2985 invoke core.clj 232] [clojure.lang.MultiFn invoke MultiFn.java 238] [dire.core$supervised_meta doInvoke core.clj 258] [clojure.lang.RestFn invoke RestFn.java 425] [clojure.lang.AFn applyToHelper AFn.java 156] [clojure.lang.RestFn applyTo RestFn.java 132] [clojure.core$apply invoke core.clj 634] [dire.core$supervise doInvoke core.clj 266] [clojure.lang.RestFn invoke RestFn.java 410] [humongorous_api.supervisor_start$start invoke supervisor_start.clj 19] [humongorous_api.core$start invoke core.clj 11] [humongorous_api.core$_main doInvoke core.clj 24] [clojure.lang.RestFn invoke RestFn.java 397] [clojure.lang.AFn applyToHelper AFn.java 152] [clojure.lang.RestFn applyTo RestFn.java 132] [humongorous_api.core main nil -1]]} humongorous-api is shutting down The last line is "humongorous-api is shutting down" which is set up here: ;; Enable command-line invocation (defn -main [& args] (try (.addShutdownHook (Runtime/getRuntime) (Thread. #(do (println "humongorous-api is shutting down") (stop)))) (start) (catch Exception e (println e)))) So... if I use the Erlang style I can not match against Object? I'm trying to figure out what mistake I have made. On Sunday, March 6, 2016 at 7:38:53 PM UTC-5, Laws wrote: > > I am a fan of Michael Drogalis's library Dire: > > https://github.com/MichaelDrogalis/dire > > And I found I was adding logging to any function I wrote to catch errors, > so I wrote a macro that added in the logging: > > (defmacro handle-error [object-to-catch symbol-to-target & args] > (let [result-fn (first args)] > `(dire/with-handler! ~symbol-to-target > ~object-to-catch > (fn [e# & args#] > (let [error-key# (str ~symbol-to-target " " e#) > error-message# (str (stack/parse-exception e#) " " e# " " > args#)] > (timbre/log :trace (str error-key# " " error-message#))) > ~(if (test/function? result-fn) > `(~result-fn)))))) > > That seemed to work. > > But on a new project, I decided I wanted to use the "Erlang" style in > Dire. I thought this would only mean changing: > > `(dire/with-handler! ~symbol-to-target > > to: > > `(dire/with-handler ~symbol-to-target > > I am not aware of anything else I need to change. > > I was also hoping to use this with Slingshot, but it seems that is only > possible with "with-handler!"? I tried a bunch of things but I could not > figure a way to make this work. > > > > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.