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

Improve exception messages when a token is not found #73

Merged
merged 2 commits into from Jan 9, 2019
Merged

Conversation

facelessuser
Copy link
Owner

In most cases, a full selector is parsed as a token, and if not, we
report the character we are at as invalid. While better context is
provided in exceptions for tokens that are fully parsed and validated,
when we don't parse a token, very little is conveyed back to the user.
There are only a few types of selectors allowed in CSS: tags, attr,
class, id, pseudo-class, pseudo-elements, and combinators. You can have
variations of these, but that is it. We cover most of these cases
already with decent context, but there are still a few case that are
just reported as invalid characters. Moving forward, we will see if the
invalid character represents the start of one of the basic, supported
types. Only attr, class, id, and pseudo-(class|element) really fall into
the category that would generate one of these ambiguous exceptions, so
identify their starting character and raise an appropriate "malformed"
selector exception.

Also remove unnecessary "+" in PAT_PSEUDO_CLASS.

In most cases, a full selector is parsed as a token, and if not, we
report the character we are at as invalid. While better context is
provided in exceptions for tokens that are fully parsed and validated,
when we don't parse a token, very little is conveyed back to the user.
There are only a few types of selectors allowed in CSS: tags, attr,
class, id, pseudo-class, pseudo-elements, and combinators. You can have
variations of these, but that is it.  We cover most of these cases
already with decent context, but there are still a few case that are
just reported as invalid characters. Moving forward, we will see if the
invalid character represents the start of one of the basic, supported
types. Only attr, class, id, and pseudo-(class|element) really fall into
the category that would generate one of these ambiguous exceptions, so
identify their starting character and raise an appropriate "malformed"
selector exception.

Also remove unnecessary "+" in PAT_PSEUDO_CLASS.
@facelessuser facelessuser added the S: approved The pull request is ready to be merged. label Jan 9, 2019
@facelessuser facelessuser merged commit 9fb1f46 into master Jan 9, 2019
@facelessuser facelessuser added this to the 1.7.0 milestone Jan 10, 2019
@facelessuser facelessuser deleted the err-msg branch January 18, 2019 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: API Related to the API. S: approved The pull request is ready to be merged. T: feature Feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant