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]>:

> 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]
> 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.
>

-- 
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