Identity ex-info exceptions as being thrown from rewrite-clj
Problem/Opportunity Rewrite-clj throws ex-info exceptions. It would be nice if a caller could easily tell if they came from rewrite-clj.
Proposed Solution
@borkdude suggested adding :type :rewrite-clj to ex-data.
Alternative Solutions None at this time.
Action I can follow up with a PR sometime soon.
A namespaced keyword would allow usage with derive. This is what I've done in SCI: :sci/error for general errors.
A namespaced keyword would allow usage with derive. This is what I've done in SCI: :sci/error for general errors.
Cool, thanks, I'll take a peek at sci for inspiration.
While I'm looking at exceptions I've started to look at this one.
Following sci's example we'll have a base exception :type of :rewrite-clj/error.
It will have descendants:
rewrite-clj.error/parsewill have descendants:rewrite-clj.error/unmatched-delimiterrewrite-clj.error/eof(could optionally distinguish different reasons for eof with descendants, but probably won't yet)rewrite-clj.error/invalidwill have descendantsrewrite-clj.error/invalid-keywordrewrite-clj.error/invalid-symbolrewrite-clj.error/invalid-namespaced-map- ...
I'll review and update as I work my way through what rewrite-clj currently throws. (and what our usage of tools.reader currently throws, for that matter).
As always, feedback and ideas are welcome.
An alternative to being very granular for invalid errors is to include what rewrite-clj was trying to parse as a separate map entry in the ex-info data. Our node tag is not terribly granular so this might send me to finally look at #114.