What you want is currently not possible. If you need this functionality, I'll take a patch for tools.reader that adds a :nil-on-unreadable option to clojure.tools.reader.edn/read. Il giorno 16/gen/2014 11.05, "t x" <txrev...@gmail.com> ha scritto:
> Either you misunderstood my question or I misunderstood your answer. > > I don't want the entire expression to return nil. I only want the > _unparsable_ part to return nil. > > Thus, the above answer should be > > {:tag :message > :chan ni} > > rather than > > nil > > > On Thu, Jan 16, 2014 at 1:47 AM, Luc Prefontaine < > lprefonta...@softaddicts.ca> wrote: > >> Wrap the read in a try catch just return nil in the catch clause >> for this specific exception and wrap it in a function for ease >> of use. You might want to throw up any other exceptions and >> only catch this one.... >> >> Luc P. >> >> >> > I should add: this problem arises due to cljs / clojure talking over the >> > network, so: >> > >> > (*) not using serialization is NOT an option >> > >> > (*) however, I don't have to use edn/read-string + pr-str >> > >> > (*) it's perfectly fine to use different encoding/decoding methods >> > >> > >> > On Thu, Jan 16, 2014 at 12:11 AM, t x <txrev...@gmail.com> wrote: >> > >> > > Hi, >> > > >> > > Right now if I do (clojure.edn/read-string ...) on a string with a >> > > unreadable part, I get an exception. Instead, I would like to just >> get nil. >> > > For example: >> > > >> > > >> > > ## code >> > > >> > > (clojure.edn/read-string >> > > (pr-str >> > > {:tag :message >> > > :chan (async/chan 10)})) >> > > >> > > ## currently returns >> > > >> > > java.lang.RuntimeException: Unreadable form >> > > at clojure.lang.Util.runtimeException (Util.java:219) >> > > >> > > >> > > ## instead, I would like: >> > > >> > > {:tag :message >> > > :chan :nil} >> > > >> > > >> > > Is there a way to make this happen? >> > > >> > > Thanks! >> > > >> > >> > -- >> > -- >> > 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/groups/opt_out. >> > >> -- >> Luc Prefontaine<lprefonta...@softaddicts.ca> sent by ibisMail! >> >> -- >> -- >> 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/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 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/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 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/groups/opt_out.