Improve error message when parsing fails
I got error messages like TypeError: Missing parameter name at 3: https://git.new/pathToRegexpError and I was wondering how that weird url made it's way into my code
Two suggestions:
- It doeesn't look like
lexer()gets the whole error, so maybe it would be good to wrap those errors inparse()and include the whole string? - Make it clear that the url is documentation. Something like
For more information about regexp paths check https://... - I personally would prefer a link that clearly shows it's going to github instead of a link shortener, but that's just my opinion
If you're ok with me changing 1 and 2, I'm happy to prepare a pull request
- I'm not sure I understand, can you elaborate on what "the whole string"?
- Sounds good, I'm open to a PR that changes it to something like
...; visit <link> for more information. - Prefer to avoid changing for now, it's there to ensure the error docs can move or update in the future without breaking old versions of the library.
For 1, I guess the problem is that the error message gives no indication on where the error occurred. I have the same error stating something about 'missing parameter name at 2' without any details. So I have to check all my routes for potential errors. Dumping the input path will already help with handling this error.
I'm sorry I completely forgot about that. I created two merge requests that address points 1 and 2
I have created a simple version of this that shows you the problematic url. pull request #358