tree = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_DOC);
if (tree == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLDoc");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLDoc");
return -1;
}
tree = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_DOC);
if (tree == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLDoc");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLDoc");
return -1;
}
}
if (!JS_IsNullOrUndefined(setval)) {
- JS_ThrowInternalError(cx, "XMLNode.$tag$xxx is not assignable, "
- "use addChild() or node.$tags = [node1, node2, ..] "
- "syntax");
+ JS_ThrowTypeError(cx, "XMLNode.$tag$xxx is not assignable, "
+ "use addChild() or node.$tags = [node1, node2, ..] "
+ "syntax");
return -1;
}
current = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_NODE);
if (current == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLNode");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLNode");
return -1;
}
tree = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_NODE);
if (tree == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLNode");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLNode");
return -1;
}
if (current == NULL) {
tree = JS_GetOpaque(val, QJS_CORE_CLASS_ID_XML_DOC);
if (tree == NULL) {
- JS_ThrowInternalError(cx, "'this' is not XMLNode or XMLDoc");
+ JS_ThrowTypeError(cx, "value is not XMLNode or XMLDoc");
return NULL;
}
current = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_ATTR);
if (current == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLAttr");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLAttr");
return -1;
}
current = JS_GetOpaque(obj, QJS_CORE_CLASS_ID_XML_ATTR);
if (current == NULL) {
- (void) JS_ThrowInternalError(cx, "\"this\" is not an XMLAttr");
+ (void) JS_ThrowTypeError(cx, "\"this\" is not an XMLAttr");
return -1;
}
return xml.serializeToString(doc);
},
expected: `<note><to a="foo" b="bar">Tove</to><from>Jani</from></note>` },
+ { get: (doc) => {
+ try {
+ doc.note.$tag$xxx = doc.note.to;
+ } catch (e) {
+ if (e instanceof TypeError) {
+ return 'OK';
+ }
+ }
+
+ throw Error('unexpected exception');
+ },
+ expected: 'OK' },
{ doc: `<root><a>A</a><b>B</b><a>C</a></root>`,
get: (doc) => {
doc.$root.removeChildren('a');