[gxml] CharacterData.vala, Element.vala, Document.vala, DomNode.vala, NodeList.vala: use new GXml.warning f
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] CharacterData.vala, Element.vala, Document.vala, DomNode.vala, NodeList.vala: use new GXml.warning f
- Date: Fri, 23 Aug 2013 20:56:15 +0000 (UTC)
commit b56c14de4e3afcd54fcd31acced51de71df9a348
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 27 00:01:55 2013 -0400
CharacterData.vala, Element.vala, Document.vala, DomNode.vala, NodeList.vala: use new GXml.warning
facility, so we can preserve the last error code
gxml/CharacterData.vala | 8 ++++----
gxml/Document.vala | 14 +++++++-------
gxml/DomNode.vala | 2 +-
gxml/Element.vala | 2 +-
gxml/NodeList.vala | 5 ++---
5 files changed, 15 insertions(+), 16 deletions(-)
---
diff --git a/gxml/CharacterData.vala b/gxml/CharacterData.vala
index 1bca77d..bc71242 100644
--- a/gxml/CharacterData.vala
+++ b/gxml/CharacterData.vala
@@ -72,21 +72,21 @@ namespace GXml {
protected bool check_index_size (string method, int length, ulong offset, ulong? count) {
if (offset < 0) {
- GLib.warning ("INDEX_SIZE_ERR: %s called with offset '%lu' for data of length
'%lu'", method, offset, length);
+ GXml.warning (DomException.INDEX_SIZE, "%s called with offset '%lu' for data
of length '%lu'".printf (method, offset, length));
return false;
}
if (count < 0) {
- GLib.warning ("INDEX_SIZE_ERR: %s called with count '%lu'", method, count);
+ GXml.warning (DomException.INDEX_SIZE, "%s called with count '%lu'".printf
(method, count));
return false;
}
if (count != null) {
if (length < offset + count) { // < or <= ?
- GLib.warning ("INDEX_SIZE_ERR: %s called with offset '%lu' and count
'%lu' for data of length '%lu'", method, offset, count, length);
+ GXml.warning (DomException.INDEX_SIZE, "%s called with offset '%lu'
and count '%lu' for data of length '%lu'".printf (method, offset, count, length));
return false;
}
} else {
if (length <= offset) { // <= or < ?
- GLib.warning ("INDEX_SIZE_ERR: %s called with offset '%lu' for data
of length '%lu'", method, offset, length);
+ GXml.warning (DomException.INDEX_SIZE, "%s called with offset '%lu'
for data of length '%lu'".printf (method, offset, length));
return false;
}
}
diff --git a/gxml/Document.vala b/gxml/Document.vala
index 1a777ae..3262906 100644
--- a/gxml/Document.vala
+++ b/gxml/Document.vala
@@ -253,12 +253,12 @@ namespace GXml {
Xml.Node *root;
if (doc == null) // should be impossible
- GLib.warning ("INVALID_DOC_ERR: Failed to parse document, xmlDoc* was NULL");
+ GXml.warning (DomException.INVALID_DOC, "Failed to parse document, xmlDoc*
was NULL");
if (require_root) {
root = doc->get_root_element ();
if (root == null) {
- GLib.warning ("INVALID_ROOT_ERR: Could not obtain a valid root for
the document; xmlDoc*'s root was NULL");
+ GXml.warning (DomException.INVALID_ROOT, "Could not obtain a valid
root for the document; xmlDoc*'s root was NULL");
}
}
@@ -368,7 +368,7 @@ namespace GXml {
this.from_stream (instream, can);
instream.close ();
} catch (GLib.Error e) {
- GLib.warning ("INVALID_DOC_ERR: Could not load document from GFile: %s",
e.message);
+ GXml.warning (DomException.INVALID_DOC, "Could not load document from GFile:
%s".printf (e.message));
}
}
/**
@@ -616,7 +616,7 @@ namespace GXml {
*/
private void check_not_supported_html (string feature) {
if (this.doctype != null && (this.doctype.name.casefold () == "html".casefold ())) {
- GLib.warning ("NOT_SUPPORTED_ERR: HTML documents do not support '%s'",
feature); // TODO: i18n
+ GXml.warning (DomException.NOT_SUPPORTED, "HTML documents do not support
'%s'".printf (feature)); // TODO: i18n
}
}
@@ -626,7 +626,7 @@ namespace GXml {
internal static bool check_invalid_characters (string name, string subject) {
/* TODO: use Xml.validate_name instead */
if (Xml.validate_name (name, 0) != 0) { // TODO: define validity
- GLib.warning ("INVALID_CHARACTER_ERR: Provided name '%s' for '%s' is not a
valid XML name", name, subject);
+ GXml.warning (DomException.INVALID_CHARACTER, "Provided name '%s' for '%s' is
not a valid XML name".printf (name, subject));
return false;
}
@@ -666,13 +666,13 @@ namespace GXml {
if (xmldoc->get_root_element () == null) {
xmldoc->set_root_element (((Element)new_child).node);
} else {
- GLib.warning ("HIERARCHY_REQUEST_ERR: Document already has a root
element. Could not add child element with name '%s'", new_child.node_name);
+ GXml.warning (DomException.HIERARCHY_REQUEST, "Document already has a
root element. Could not add child element with name '%s'".printf (new_child.node_name));
}
} else if (new_child.node_type == NodeType.DOCUMENT_TYPE) {
if (this.doctype == null) {
this.doctype = (DocumentType)new_child;
} else {
- GLib.warning ("HIERARCHY_REQUEST_ERR: Document already has a doctype.
Could not add new doctype with name '%s'.", ((DocumentType)new_child).name);
+ GXml.warning (DomException.HIERARCHY_REQUEST, "Document already has a
doctype. Could not add new doctype with name '%s'.".printf (((DocumentType)new_child).name));
}
GLib.warning ("Appending document_types not yet supported");
} else {
diff --git a/gxml/DomNode.vala b/gxml/DomNode.vala
index b3f1440..92a86c6 100644
--- a/gxml/DomNode.vala
+++ b/gxml/DomNode.vala
@@ -50,7 +50,7 @@ namespace GXml {
protected void check_wrong_document (DomNode node) {
if (this.owner_document != node.owner_document) {
- GLib.warning ("WRONG_DOCUMENT_ERR: Node tried to interact with this document
'%p' but belonged to document '%p'", this.owner_document, node.owner_document);
+ GXml.warning (DomException.WRONG_DOCUMENT, "Node tried to interact with this
document '%p' but belonged to document '%p'".printf (this.owner_document, node.owner_document));
}
}
diff --git a/gxml/Element.vala b/gxml/Element.vala
index ada1dc6..8d37381 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -331,7 +331,7 @@ namespace GXml {
this.check_read_only ();
if (this.attributes.remove (old_attr.name) == false) {
- GLib.warning ("NOT_FOUND_ERR: No child with name '%s' exists in node '%s'",
old_attr.name, this.node_name);
+ GXml.warning (DomException.NOT_FOUND, "No child with name '%s' exists in node
'%s'".printf (old_attr.name, this.node_name));
}
return old_attr;
diff --git a/gxml/NodeList.vala b/gxml/NodeList.vala
index bf55923..f02f076 100644
--- a/gxml/NodeList.vala
+++ b/gxml/NodeList.vala
@@ -555,7 +555,7 @@ namespace GXml {
child = child->next;
}
if (child == null) {
- this.owner.last_error = new DomError.NOT_FOUND ("ref_child not found.");
+ GXml.warning (DomException.NOT_FOUND, "ref_child '%s' not found, was supposed
to have '%s' inserted before it.".printf (ref_child.node_name, new_child.node_name));
return null;
// TODO: provide a more useful description of ref_child, but there are so
many different types
} else {
@@ -594,8 +594,7 @@ namespace GXml {
// it is a valid child
child->replace (((BackedNode)new_child).node);
} else {
- this.owner.last_error = new DomError.NOT_FOUND ("old_child not
found");
- // TODO: provide more useful descr. of old_child
+ GXml.warning (DomException.NOT_FOUND, "old_child '%s' not found,
tried to replace with '%s'".printf (old_child.node_name, new_child.node_name));
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]