Skip to content
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

feat: add pattern and path to regexp create errors #2477 #2485

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

jasoniangreen
Copy link
Collaborator

@jasoniangreen jasoniangreen commented Aug 4, 2024

What issue does this pull request resolve?

#2477 - Wrap regexp instantiation in try/catch to add pattern and schema path to the error message

What changes did you make?

Wrapped both the regular and codegen'd versions of the pattern keyword regexp creation

Is there anything that requires more attention while reviewing?

Not sure if there is a better way to do the codegen, I did try using gen.try etc but couldn't figure it out.

const u = it.opts.unicodeRegExp ? "u" : ""
const regExp = $data ? _`(new RegExp(${schemaCode}, ${u}))` : usePattern(cxt, schema)
Copy link
Collaborator Author

@jasoniangreen jasoniangreen Aug 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never using opts.code.regExp? Is that intentional?

throw new Error(e.message + ' | pattern ' + ${schemaCode} + ' at ' + ${it.errSchemaPath})
}
})()`
: usePattern(cxt, schema)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is probably a way to build this with gen.try etc but maybe this is ok? I'm still getting my head around codegen stuff.

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

Successfully merging this pull request may close these issues.

1 participant