[gxml] example.vala: remove obsolete try-catch



commit c9c2606842a2049c56d17e5896214c4f48c2e4eb
Author: Richard Schwarting <aquarichy gmail com>
Date:   Fri Aug 23 09:57:16 2013 -0400

    example.vala: remove obsolete try-catch

 examples/vala/example.vala |   70 +++++++++++++++----------------------------
 1 files changed, 25 insertions(+), 45 deletions(-)
---
diff --git a/examples/vala/example.vala b/examples/vala/example.vala
index f4aa43f..f0d566f 100755
--- a/examples/vala/example.vala
+++ b/examples/vala/example.vala
@@ -4,28 +4,24 @@ void create_a_document () {
        string[] authors = { "John Green", "Jane Austen", "J.D. Salinger" };
        string[] titles = { "The Fault in Our Stars", "Pride & Prejudice", "Nine Stories" };
 
-       try {
-               Document doc = new Document ();
-               Element root = doc.create_element ("Bookshelf");
-               doc.append_child (root);
-               Element owner = doc.create_element ("Owner");
-               root.append_child (owner);
-               owner.set_attribute ("fullname", "John Green");
-
-               Element books = doc.create_element ("Books");
-               root.append_child (books);
-
-               for (int i = 0; i < authors.length; i++) {
-                       Element book = doc.create_element ("Book");
-                       book.set_attribute ("author", authors[i]);
-                       book.set_attribute ("title", titles[i]);
-                       books.append_child (book);
-               }
-
-               stdout.printf ("create_a_document:\n%s\n", doc.to_string (true, 8));
-       } catch (GLib.Error e) {
-               stderr.printf ("%s\n", e.message);
+       Document doc = new Document ();
+       Element root = doc.create_element ("Bookshelf");
+       doc.append_child (root);
+       Element owner = doc.create_element ("Owner");
+       root.append_child (owner);
+       owner.set_attribute ("fullname", "John Green");
+
+       Element books = doc.create_element ("Books");
+       root.append_child (books);
+
+       for (int i = 0; i < authors.length; i++) {
+               Element book = doc.create_element ("Book");
+               book.set_attribute ("author", authors[i]);
+               book.set_attribute ("title", titles[i]);
+               books.append_child (book);
        }
+
+       stdout.printf ("create_a_document:\n%s\n", doc.to_string (true, 8));
 }
 
 void create_a_document_from_a_string () {
@@ -42,12 +38,8 @@ void create_a_document_from_a_string () {
 </Books>
 </Bookshelf>""";
 
-       try {
-               doc = new Document.from_string (xml);
-               stdout.printf ("create_a_document_from_a_string:\n%s\n", doc.to_string (true, 8));
-       } catch (GXml.DomError e) {
-               stderr.printf ("%s\n", e.message);
-       }
+       doc = new Document.from_string (xml);
+       stdout.printf ("create_a_document_from_a_string:\n%s\n", doc.to_string (true, 8));
 }
 
 void create_a_document_from_a_file () {
@@ -55,34 +47,22 @@ void create_a_document_from_a_file () {
        Cancellable can = new Cancellable ();
        Document doc;
 
-       try {
-               doc = new Document.from_gfile (f, can);
-               stdout.printf ("create_a_document_from_a_file:\n%s\n", doc.to_string (true, 8));
-       } catch (DomError e) {
-               stderr.printf ("%s\n", e.message);
-       }
+       doc = new Document.from_gfile (f, can);
+       stdout.printf ("create_a_document_from_a_file:\n%s\n", doc.to_string (true, 8));
 }
 
 void create_a_document_from_a_path () {
        Document doc;
 
-       try {
-               doc = new Document.from_path ("bookshelf.xml");
-               stdout.printf ("create_a_document_from_a_path:\n%s\n", doc.to_string (true, 8));
-       } catch (DomError e) {
-               stderr.printf ("%s\n", e.message);
-       }
+       doc = new Document.from_path ("bookshelf.xml");
+       stdout.printf ("create_a_document_from_a_path:\n%s\n", doc.to_string (true, 8));
 }
 
 void saving_a_document_to_a_path () {
        Document doc;
 
-       try {
-               doc = new Document.from_path ("bookshelf.xml");
-               doc.save_to_path ("bookshelf2.xml");
-       } catch (DomError e) {
-               stderr.printf ("%s\n", e.message);
-       }
+       doc = new Document.from_path ("bookshelf.xml");
+       doc.save_to_path ("bookshelf2.xml");
 }
 
 int main (string[] args) {


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