Skip to content

Commit 20a7f75

Browse files
committed
build the correct error
1 parent dedf6ff commit 20a7f75

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/main/java/org/htmlunit/javascript/host/css/CSSGroupingRule.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ else if (JavaScriptEngine.isUndefined(position)) {
121121
ex.code));
122122
}
123123
}
124-
throw JavaScriptEngine.syntaxError(e.getMessage());
124+
throw JavaScriptEngine.asJavaScriptException(
125+
getWindow(),
126+
new org.htmlunit.javascript.host.dom.DOMException(
127+
e.getMessage(),
128+
org.htmlunit.javascript.host.dom.DOMException.SYNTAX_ERR));
125129
}
126130
}
127131

src/main/java/org/htmlunit/javascript/host/dom/Document.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ else if (resolver instanceof PrefixResolver) {
580580
return xPathResult;
581581
}
582582
catch (final Exception e) {
583-
throw JavaScriptEngine.syntaxError("Failed to execute 'evaluate': " + e.getMessage());
583+
throw JavaScriptEngine.asJavaScriptException(
584+
getWindow(),
585+
new org.htmlunit.javascript.host.dom.DOMException(
586+
"Failed to execute 'evaluate': " + e.getMessage(),
587+
org.htmlunit.javascript.host.dom.DOMException.SYNTAX_ERR));
584588
}
585589
}
586590

@@ -982,9 +986,12 @@ public Node querySelector(final String selectors) {
982986
return null;
983987
}
984988
catch (final CSSException e) {
985-
throw JavaScriptEngine.syntaxError(
986-
"An invalid or illegal selector was specified (selector: '"
987-
+ selectors + "' error: " + e.getMessage() + ").");
989+
throw JavaScriptEngine.asJavaScriptException(
990+
getWindow(),
991+
new org.htmlunit.javascript.host.dom.DOMException(
992+
"An invalid or illegal selector was specified (selector: '"
993+
+ selectors + "' error: " + e.getMessage() + ").",
994+
org.htmlunit.javascript.host.dom.DOMException.SYNTAX_ERR));
988995
}
989996
}
990997

@@ -1001,8 +1008,12 @@ public NodeList querySelectorAll(final String selectors) {
10011008
return NodeList.staticNodeList(this, getDomNodeOrDie().querySelectorAll(selectors));
10021009
}
10031010
catch (final CSSException e) {
1004-
throw JavaScriptEngine.syntaxError("An invalid or illegal selector was specified (selector: '"
1005-
+ selectors + "' error: " + e.getMessage() + ").");
1011+
throw JavaScriptEngine.asJavaScriptException(
1012+
getWindow(),
1013+
new org.htmlunit.javascript.host.dom.DOMException(
1014+
"An invalid or illegal selector was specified (selector: '"
1015+
+ selectors + "' error: " + e.getMessage() + ").",
1016+
org.htmlunit.javascript.host.dom.DOMException.SYNTAX_ERR));
10061017
}
10071018
}
10081019

0 commit comments

Comments
 (0)