[gxml/gsoc2013: 64/69] DomException.vala: add facility to set the last DomException set; ooo, classic error codes



commit 04027b595fff508885fc9f9760d45f281765b24a
Author: Richard Schwarting <aquarichy gmail com>
Date:   Sat Jul 27 00:01:54 2013 -0400

    DomException.vala: add facility to set the last DomException set; ooo, classic error codes

 gxml/DomException.vala |  144 ++++++++++++++++++++++++++----------------------
 1 files changed, 79 insertions(+), 65 deletions(-)
---
diff --git a/gxml/DomException.vala b/gxml/DomException.vala
index 4cfc4a0..d7cb5ad 100644
--- a/gxml/DomException.vala
+++ b/gxml/DomException.vala
@@ -22,74 +22,88 @@
  *      Daniel Espinosa <esodan gmail com>
  */
 
-/**
- * Describes various error states. For more, see
- *
- * Version: DOM Level 1 Core
- * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-BBACDC08]]
- */
-public enum GXml.DomException {
-       /* These error codes are from the IDL: TODO: find out when I should use them */
-       /* TODO: probably want to document them :) */
-       /**
-        * An index or size is out of range, like less than 0 or exceeding some upper bound.
-        */
-       INDEX_SIZE,
-       /**
-        * Text exceeds the maximum size supported in our string implementation.
-        */ // TODO: figure out what the limits of strings are in vala
-       DOMSTRING_SIZE,
-       /**
-        * A node asked to be inserted into an invalid location.
-        */
-       HIERARCHY_REQUEST,
-       /**
-        * A node created for one document wanted to be used in another.
-        */
-       WRONG_DOCUMENT,
-       /**
-        * An invalid character was found in a name.
-        */ // TODO: which characters are invalid?
-       INVALID_CHARACTER,
-       /**
-        * Tried to specify data for a node that did not support it.
-        */
-       NO_DATA_ALLOWED,
-       /**
-        * Attempted to modify a read-only node.
-        */
-       NO_MODIFICATION_ALLOWED,
-       /**
-        * A reference to a non-existent node was made.
-        */
-       NOT_FOUND,
-       /**
-        * A request was made for something that this implementation does not support.
-        */
-       NOT_SUPPORTED,
-       /**
-        * An element tried to make use of an attribute already attached to another element.
-        */
-       INUSE_ATTRIBUTE,
+namespace GXml {
+       public static DomException last_error = DomException.NONE;
+
+       public static void warning (GXml.DomException exception, string message) {
+               GXml.last_error = exception;
+               GLib.warning ("%s", message);
+       }
 
-       /* These error codes are mine,
-          and should perhaps come from a separate domain */
-       /**
-        * Generic error in creating the DOM.
-        */
-       DOM,
-       /**
-        * A document could not be parsed due to invalid XML.
-        */
-       INVALID_DOC,
        /**
-        * A document lacked a root element.
+        * Describes various error states. For more, see
+        *
+        * Version: DOM Level 1 Core
+        * URL: [[http://www.w3.org/TR/DOM-Level-1/level-one-core.html#ID-BBACDC08]]
         */
-        INVALID_ROOT;
-}
+       public enum DomException {
+               /**
+                * Indicates that there has not been a recent error
+                */
+               NONE,
+
+               /* These error codes are from the IDL: TODO: find out when I should use them */
+               /* TODO: probably want to document them :) */
+               /**
+                * An index or size is out of range, like less than 0 or exceeding some upper bound.
+                */
+               INDEX_SIZE,
+               /**
+                * Text exceeds the maximum size supported in our string implementation.
+                */ // TODO: figure out what the limits of strings are in vala
+               DOMSTRING_SIZE,
+               /**
+                * A node asked to be inserted into an invalid location.
+                */
+               HIERARCHY_REQUEST,
+               /**
+                * A node created for one document wanted to be used in another.
+                */
+               WRONG_DOCUMENT,
+               /**
+                * An invalid character was found in a name.
+                */ // TODO: which characters are invalid?
+               INVALID_CHARACTER,
+               /**
+                * Tried to specify data for a node that did not support it.
+                */
+               NO_DATA_ALLOWED,
+               /**
+                * Attempted to modify a read-only node.
+                */
+               NO_MODIFICATION_ALLOWED,
+               /**
+                * A reference to a non-existent node was made.
+                */
+               NOT_FOUND,
+               /**
+                * A request was made for something that this implementation does not support.
+                */
+               NOT_SUPPORTED,
+               /**
+                * An element tried to make use of an attribute already attached to another element.
+                */
+               INUSE_ATTRIBUTE,
+
+               /* These error codes are mine,
+                  and should perhaps come from a separate domain */
+               /**
+                * Generic error in creating the DOM.
+                */
+               DOM,
+               /**
+                * A document could not be parsed due to invalid XML.
+                */
+               INVALID_DOC,
+               /**
+                * A document lacked a root element.
+                */
+               INVALID_ROOT,
+       }
 
-// TODO: remove after transitioning tests
-public errordomain GXml.DomError {
-       DUMMY;
+       // TODO: remove after transitioning tests
+       public errordomain DomError {
+               DUMMY;
+       }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]