Fork me on GitHub
#rewrite-clj
<
2022-09-12
>
Ferdinand Beyer09:09:57

I'd like to catch parse errors and extract the location (row, column). Unfortunately, the ex-data thrown in reader.cljc only puts this information into the message. I have a PR ready to add row and col to ex-data, if you agree this is useful?

Ferdinand Beyer09:09:05

While looking into :row and :col (see above), I think I found a bug: When parsing this with ClojureScript:

(p/parse-string "(defn foo [)")
...I do not get ExceptionInfo with a useful Unmatched delimiter message like in Clojure, but: TypeError: Right-hand side of 'instanceof' is not an object

❌ 1
Ferdinand Beyer13:09:48

Yeah no, that was on me. Don't (catch Exception _) in .cljc files 😉

borkdude10:09:39

@fb Yes, I think that would be good to have.

borkdude10:09:45

edamame already does this

👍 1
Ferdinand Beyer10:09:14

PR here: https://github.com/clj-commons/rewrite-clj/pull/181 I think the tests will not pass because of aforementioned issue with TypeError in ClojureScript. I'm not sure if I can look into this right now and I think it is unrelated to my changes.

lread11:09:18

@fb seems like a good idea to me too! Thanks for thinking of it and taking a stab at it. I’ll take a peek at your PR sometime soon.

👍 1
lread14:09:02

Thanks for the PR, update, and your contribution @fb!

Ferdinand Beyer14:09:27

My pleasure! It was such a tiny contribution though 😄

lread14:09:23

But valuable, yeah? And you thought of it and did it!

Ferdinand Beyer14:09:11

Yes, I'm selfish. I no longer want to parse the exception message! 😛

lread14:09:09

Selfish and generous, and good combo!

😆 1