Skip to content

Improve error message when parsing fails #336

@simhnna

Description

@simhnna
Contributor

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

Activity

blakeembrey

blakeembrey commented on Oct 17, 2024

@blakeembrey
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

abs-lme commented on Apr 1, 2025

@abs-lme

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.

added a commit that references this issue on Apr 7, 2025
0239249
linked a pull request that will close this issue on Apr 7, 2025
simhnna

simhnna commented on Apr 7, 2025

@simhnna
ContributorAuthor

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

SlothScript

SlothScript commented on Apr 15, 2025

@SlothScript

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

linked a pull request that will close this issue on May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @blakeembrey@UlisesGascon@simhnna@SlothScript@abs-lme

      Issue actions

        Improve error message when parsing fails · Issue #336 · pillarjs/path-to-regexp