[gxml/gsoc2013: 111/150] examples/vala/example.vala: remove obsolete GError handling
- From: Richard Hans Schwarting <rschwart src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/gsoc2013: 111/150] examples/vala/example.vala: remove obsolete GError handling
- Date: Sat, 24 Aug 2013 17:38:34 +0000 (UTC)
commit d39bac4d729a42d0f1ecabc62b3db1b94a5ac718
Author: Richard Schwarting <aquarichy gmail com>
Date: Sun Jul 28 01:30:11 2013 -0400
examples/vala/example.vala: remove obsolete GError handling
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]