Skip to content

Improve error message when parsing fails #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
simhnna opened this issue Oct 17, 2024 · 4 comments · May be fixed by #356
Open

Improve error message when parsing fails #336

simhnna opened this issue Oct 17, 2024 · 4 comments · May be fixed by #356

Comments

@simhnna
Copy link

simhnna commented Oct 17, 2024

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:

  1. It doeesn't look like lexer() gets the whole error, so maybe it would be good to wrap those errors in parse() and include the whole string?
  2. Make it clear that the url is documentation. Something like For more information about regexp paths check https://...
  3. 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

@blakeembrey
Copy link
Member

  1. I'm not sure I understand, can you elaborate on what "the whole string"?
  2. Sounds good, I'm open to a PR that changes it to something like ...; visit <link> for more information.
  3. 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.

@abs-lme
Copy link

abs-lme commented Apr 1, 2025

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.

simhnna added a commit to simhnna/path-to-regexp that referenced this issue Apr 7, 2025
Without the path users need to search all their code for a malformed
path or debug to find the issue

Closes: pillarjs#336
@simhnna simhnna linked a pull request Apr 7, 2025 that will close this issue
@simhnna
Copy link
Author

simhnna commented Apr 7, 2025

I'm sorry I completely forgot about that. I created two merge requests that address points 1 and 2

@SlothScript
Copy link

I have created a simple version of this that shows you the problematic url. pull request #358

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants