[gxml/gsoc2013: 87/150] Element.vala: handle spec'd errors
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/gsoc2013: 87/150] Element.vala: handle spec'd errors
- Date: Sat, 24 Aug 2013 17:36:33 +0000 (UTC)
commit a4d448ecc3ef86385e68c1419d3b465a98126c13
Author: Richard Schwarting <aquarichy gmail com>
Date: Sat Jul 27 00:01:54 2013 -0400
Element.vala: handle spec'd errors
gxml/Element.vala | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gxml/Element.vala b/gxml/Element.vala
index 51bf1e3..8d204c4 100644
--- a/gxml/Element.vala
+++ b/gxml/Element.vala
@@ -270,6 +270,9 @@ namespace GXml {
* @param name The name of the attribute to unset.
*/
public void remove_attribute (string name) {
+ this.check_read_only (); // TODO: check all this.check_*, and see if we should be
aborting the current functions on failure or just warn, like here
+
+
this.attributes.remove (name);
}
/**
@@ -299,6 +302,12 @@ namespace GXml {
* Elsewise, null is returned.
*/
public Attr set_attribute_node (Attr new_attr) {
+ // TODO: INUSE_ATTRIBUTE_ERR if new_attr already belongs to another element
+
+ this.check_read_only ();
+
+ this.check_wrong_document (new_attr);
+
// TODO: need to actually associate this with the libxml2 structure!
// TODO: need to do that at the time of saving. We don't right now :|
Attr old = this.attributes.lookup (new_attr.name);
@@ -319,8 +328,16 @@ namespace GXml {
* it wasn't found.
*/
public Attr remove_attribute_node (Attr old_attr) {
+ Attr old;
+
+ this.check_read_only ()
+
// TODO: need to check for nulls. < Nope, ? controls that.
- this.attributes.remove (old_attr.name);
+ old = this.attributes.remove (old_attr.name);
+ if (old == null) {
+ GLib.warning ("NOT_FOUND_ERR: No child with name '%s' exists in node '%s'",
old_attr.name, this.node_name);
+ }
+
return old_attr;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]