@@ -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