Skip to content

Commit a1219fa

Browse files
committed
CSSGroupingRule several fixes to throw the correct error
1 parent 820d5e4 commit a1219fa

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
<body>
1010
<release version="4.10.0" date="February xx, 2025" description="Bugfixes">
11+
<action type="fix" dev="rbri">
12+
CSSGroupingRule several fixes to throw the correct error.
13+
</action>
1114
<action type="fix" dev="rbri">
1215
HTMLInputElement value/selectionStart/selectionEnd properties throws the correct error (InvalidStateError).
1316
</action>

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,14 @@ else if (JavaScriptEngine.isUndefined(position)) {
114114
return positionInt;
115115
}
116116
catch (final DOMException ex) {
117-
throw JavaScriptEngine.throwAsScriptRuntimeEx(ex);
117+
throw JavaScriptEngine.asJavaScriptException(
118+
getWindow(),
119+
new org.htmlunit.javascript.host.dom.DOMException(
120+
ex.getMessage(),
121+
ex.code));
118122
}
119123
}
120-
throw JavaScriptEngine.throwAsScriptRuntimeEx(e);
124+
throw JavaScriptEngine.syntaxError(e.getMessage());
121125
}
122126
}
123127

@@ -133,7 +137,11 @@ public void deleteRule(final int position) {
133137
refreshCssRules();
134138
}
135139
catch (final DOMException e) {
136-
throw JavaScriptEngine.throwAsScriptRuntimeEx(e);
140+
throw JavaScriptEngine.asJavaScriptException(
141+
getWindow(),
142+
new org.htmlunit.javascript.host.dom.DOMException(
143+
e.getMessage(),
144+
e.code));
137145
}
138146
}
139147

0 commit comments

Comments
 (0)