Re: How do I return the data I need from this Exception?
I see no code to ever call (timbre/log :trace (str "in catch-exceptions our reply was: " reply)) Probably just a copy error, other than that things look correct. The JVM is complex, but strange things happening are pretty much always related to programmer errors. If you add that line things should work as expected? Cheers, /thomas On Thursday, October 8, 2015 at 8:35:18 AM UTC+2, Lawrence Krubner wrote: > > I'm thinking that I've misunderstood something about how to catch an > Exception. I have these 2 functions: > > (defn catch-exceptions [e this-users-conversation] > (try > (timbre/log :trace (str "in catch-exceptions our exception was: " e)) > (let [error (:object (ex-data e)) > status (if (:status error) >(:status error) >500) > body (if (:body error) > (:body error) > (str e)) > intent (if (:intent this-users-conversation) >(:intent this-users-conversation) >"api") > reply {:message body :status status :intent intent}] > reply) > (catch Exception e (println "in catch-exceptions we triggered this > exception: " e > > (defn pull-response-from-query [this-users-conversation function-to-call] > "Formatting exceptions as Peter requested so the iPhone app only needs > to check the top-level status." > (try > (function-to-call this-users-conversation) > (catch Exception e (catch-exceptions e this-users-conversation > > > Testing in the terminal, and feeding in garbage in a deliberate attempt to > trigger the exception, I see this line over and over again: > > (timbre/log :trace (str "in catch-exceptions our exception was: " e)) > > but I never get this line: > > (timbre/log :trace (str "in catch-exceptions our reply was: " > reply)) > > nor do I ever see: > > "in catch-exceptions we triggered this exception: " > > What am I doing wrong? > > > > > -- 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.
Re: How do I return the data I need from this Exception?
That the second logging line did not print when the first one did will continue to baffle me. There is absolutely no reason why that should happen. When a println statement goes missing the cause is usually 1 of 2 things: the println was on a background thread, or there was an uncaught exception. But neither apply in this case. I am absolutely baffled. But I suppose it does not matter. The JVM is complex and sometimes strange things happen. I worked around the immediate issue with (throw) and I built a separation execution path to handle the exceptions that are thrown, but I don't like having this separate execution path. I want to bring the exception back into the normal flow of the program. I know there are libraries out there such as Hara/Ribol and I assume they do something like what I want. I can give them a look. On Thursday, October 8, 2015 at 4:01:14 AM UTC-4, Di Xu wrote: > > Well, I think you just misunderstand exception and try..catch expression. > > catch subexpression (in your case println) will evaluated only when try > subexpression (in your case log & let) throws exception. > > Thanks, > Di Xu > > 2015-10-08 14:35 GMT+08:00 Lawrence Krubner>: > >> I'm thinking that I've misunderstood something about how to catch an >> Exception. I have these 2 functions: >> >> (defn catch-exceptions [e this-users-conversation] >> (try >> (timbre/log :trace (str "in catch-exceptions our exception was: " e)) >> (let [error (:object (ex-data e)) >> status (if (:status error) >>(:status error) >>500) >> body (if (:body error) >> (:body error) >> (str e)) >> intent (if (:intent this-users-conversation) >>(:intent this-users-conversation) >>"api") >> reply {:message body :status status :intent intent}] >> reply) >> (catch Exception e (println "in catch-exceptions we triggered this >> exception: " e >> >> (defn pull-response-from-query [this-users-conversation function-to-call] >> "Formatting exceptions as Peter requested so the iPhone app only needs >> to check the top-level status." >> (try >> (function-to-call this-users-conversation) >> (catch Exception e (catch-exceptions e this-users-conversation >> >> >> Testing in the terminal, and feeding in garbage in a deliberate attempt >> to trigger the exception, I see this line over and over again: >> >> (timbre/log :trace (str "in catch-exceptions our exception was: " e)) >> >> but I never get this line: >> >> (timbre/log :trace (str "in catch-exceptions our reply was: " >> reply)) >> >> nor do I ever see: >> >> "in catch-exceptions we triggered this exception: " >> >> What am I doing wrong? >> >> >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com . >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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.
Re: How do I return the data I need from this Exception?
Well, I think you just misunderstand exception and try..catch expression. catch subexpression (in your case println) will evaluated only when try subexpression (in your case log & let) throws exception. Thanks, Di Xu 2015-10-08 14:35 GMT+08:00 Lawrence Krubner: > I'm thinking that I've misunderstood something about how to catch an > Exception. I have these 2 functions: > > (defn catch-exceptions [e this-users-conversation] > (try > (timbre/log :trace (str "in catch-exceptions our exception was: " e)) > (let [error (:object (ex-data e)) > status (if (:status error) >(:status error) >500) > body (if (:body error) > (:body error) > (str e)) > intent (if (:intent this-users-conversation) >(:intent this-users-conversation) >"api") > reply {:message body :status status :intent intent}] > reply) > (catch Exception e (println "in catch-exceptions we triggered this > exception: " e > > (defn pull-response-from-query [this-users-conversation function-to-call] > "Formatting exceptions as Peter requested so the iPhone app only needs > to check the top-level status." > (try > (function-to-call this-users-conversation) > (catch Exception e (catch-exceptions e this-users-conversation > > > Testing in the terminal, and feeding in garbage in a deliberate attempt to > trigger the exception, I see this line over and over again: > > (timbre/log :trace (str "in catch-exceptions our exception was: " e)) > > but I never get this line: > > (timbre/log :trace (str "in catch-exceptions our reply was: " > reply)) > > nor do I ever see: > > "in catch-exceptions we triggered this exception: " > > What am I doing wrong? > > > > > -- > 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. > -- 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.
How do I return the data I need from this Exception?
I'm thinking that I've misunderstood something about how to catch an Exception. I have these 2 functions: (defn catch-exceptions [e this-users-conversation] (try (timbre/log :trace (str "in catch-exceptions our exception was: " e)) (let [error (:object (ex-data e)) status (if (:status error) (:status error) 500) body (if (:body error) (:body error) (str e)) intent (if (:intent this-users-conversation) (:intent this-users-conversation) "api") reply {:message body :status status :intent intent}] reply) (catch Exception e (println "in catch-exceptions we triggered this exception: " e (defn pull-response-from-query [this-users-conversation function-to-call] "Formatting exceptions as Peter requested so the iPhone app only needs to check the top-level status." (try (function-to-call this-users-conversation) (catch Exception e (catch-exceptions e this-users-conversation Testing in the terminal, and feeding in garbage in a deliberate attempt to trigger the exception, I see this line over and over again: (timbre/log :trace (str "in catch-exceptions our exception was: " e)) but I never get this line: (timbre/log :trace (str "in catch-exceptions our reply was: " reply)) nor do I ever see: "in catch-exceptions we triggered this exception: " What am I doing wrong? -- 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.