Skip to content

Commit

Permalink
Make sure thrown thing is an Error
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0838 committed Mar 31, 2024
1 parent 7568953 commit b2e6b2b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion parse-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ class InvalidCharacterError extends Error {
}
}

class SpecError extends Error {
constructor(...args) {
super(...args);
this.name = "SpecError";
}
}

function preprocess(str) {
// Turn a string into an array of code points,
// following the preprocessing cleanup rules.
Expand Down Expand Up @@ -110,7 +117,7 @@ function tokenize(str) {
if(num === undefined)
num = 1;
if(num > 3)
throw "Spec Error: no more than three codepoints of lookahead.";
throw new SpecError("no more than three codepoints of lookahead.");
return codepoint(i+num);
};
var consume = function(num) {
Expand Down

0 comments on commit b2e6b2b

Please sign in to comment.