Just pull the exception out of the loop logic:
(go
(loop [xs (range 10)]
(if-let [x (first xs)]
(if (= ::error (try (println x) (catch Throwable t ::error)))
(recur (rest x))))))
- James
On 22 January 2014 11:05, László Török <[email protected]> wrote:
> Hi,
>
> I have a processing loop in a go block and I wanted to make sure that the
> processing continue with the next iteration if an exception is thrown.
>
> The following code doesn't seem to be accepted by the go macro:
>
> (go
> (loop [xs (range 10)]
> (when-let [x (first xs)]
> (try
> (println x)
> (recur (rest x))
> (catch Throwable t nil)))))
>
> as it returns IllegalArgumentException No implementation of method:
> :emit-instruction of protocol:
> #'clojure.core.async.impl.ioc-macros/IEmittableInstruction found for class:
> clojure.core.async.impl.ioc_macros.Jmp
>
> I can't think of an alternative right now, any ideas?
>
> --
> László Török
>
> --
> --
> 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/groups/opt_out.
>
--
--
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/groups/opt_out.