Skip to content

Commit

Permalink
Document - several fixes to throw the correct error
Browse files Browse the repository at this point in the history
  • Loading branch information
rbri committed Feb 3, 2025
1 parent 44c0e43 commit 8920deb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

<body>
<release version="4.10.0" date="February xx, 2025" description="Bugfixes">
<action type="fix" dev="rbri">
Document - several fixes to throw the correct error.
</action>
<action type="fix" dev="rbri">
XMLHttpRequest - several fixes to throw the correct error.
</action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public void put(final String name, final Scriptable start, final Object value) {
}
catch (final IllegalArgumentException e) {
// is it the right place or should Rhino throw a RuntimeError instead of an IllegalArgumentException?
throw JavaScriptEngine.reportRuntimeError("'set "
throw JavaScriptEngine.typeError("'set "
+ name + "' called on an object that does not implement interface " + getClassName());
}
}
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/org/htmlunit/javascript/host/dom/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -875,9 +875,13 @@ public void setBody(final HTMLElement htmlElement) {
}
return;
}
throw JavaScriptEngine.reportRuntimeError("Failed to set the 'body' property on 'Document': "
+ "The new body element is of type '" + htmlElement.getTagName() + "'. "
+ "It must be either a 'BODY' or 'FRAMESET' element.");
throw JavaScriptEngine.asJavaScriptException(
getWindow(),
new org.htmlunit.javascript.host.dom.DOMException(
"Failed to set the 'body' property on 'Document': "
+ "The new body element is of type '" + htmlElement.getTagName() + "'. "
+ "It must be either a 'BODY' or 'FRAMESET' element.",
org.htmlunit.javascript.host.dom.DOMException.HIERARCHY_REQUEST_ERR));
}

/**
Expand Down

0 comments on commit 8920deb

Please sign in to comment.