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 <[email protected] 
> <javascript:>>:
>
>> 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 [email protected] 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> 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 [email protected] <javascript:>.
>> 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 [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to