Welcome! Please see the About page for a little more info on how this works.

+1 vote
in Errors by

The messages in the exceptions thrown by the readers would be much more informative if they included readily available information. There are many instances of this, but to name a few specific instances (all from LispReader.java, though there in most cases there are corresponding problems in EdnReader.java):

  • If the RegexReader class hits an unexpected EOF, it reports "EOF while reading regex". It would be helpful if the message included the first few characters of the regex it was trying to read -- available in sb -- as a guide to the person trying to locate the problem.

  • The same logic applies to StringReader.

  • In NamespaceMapReader, the error thrown if the namespaced map is not in fact a map could include the namespace symbol.

  • Whenever an odd number of elements in a map is detected, the exception could at least report the number of elements that the bad map did include, something like: "Map literal cannot contain 7 forms. Map literals must contain an even number of forms." Even better would be the first few forms.

  • The "Metadata can only be applied to IMetas" exception in MetaReader is not nearly as helpful as it could be. At the very least it should report the class of the thing that is not an IMeta.

  • With an additional argument, readDelimitedList could report the kind of thing that it was reading in the event that it hit the EOF. Without the additional argument it still report that it hit an EOF while trying to read the first or 4th or 29 element of a collection.

1 Answer

0 votes
Reference: https://clojure.atlassian.net/browse/CLJ-2173 (reported by alex+import)