Error types for failure states?
tmcw opened this issue · 4 comments
I just started to work on an API section for the readme here, and I'm able to reproduce a TypeError when something fails in the ESRI parser, but it looks like there are more ways for node-srs to throw. I'm wondering if all these will be TypeErrors, and what their messages will be: it would be convenient to have pretty simple & understandable failure states that we can differentiate and present to users.
- API Section: woot, thanks
- regarding errors: I think it could be made more granular but now its basically "throw a TypeError if node-srs thinks its unlikely a proj4 code was detected". All other complexity or failure states are not really well thought at this point.
In Python, I'd raise TypeError if a positional argument was a string when the function expected an integer, and a ValueError if the function expected a string encoding an SRS and received a haiku. What do Javascript developers do for a generic ValueError?
Not sure, @tmcw you have an opinion?
https://twitter.com/izs/status/160536922165489664
In node-core seems to be going with just TypeError
and Error
for everything else. If there's a particular need to distinguish classes of errors, then there is a code
property attached to the error, e.g. ENOENT
.