[folks] Add some more detailed validation/error reporting to the importing tool.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add some more detailed validation/error reporting to the importing tool.
- Date: Fri, 10 Sep 2010 19:13:53 +0000 (UTC)
commit 17d54039f6b4a505ca83fbfb88b6dcccb9cd9d8f
Author: Travis Reitter <travis reitter collabora co uk>
Date: Fri Sep 10 12:13:42 2010 -0700
Add some more detailed validation/error reporting to the importing tool.
tools/import-pidgin.vala | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/tools/import-pidgin.vala b/tools/import-pidgin.vala
index 22790a4..48a6170 100644
--- a/tools/import-pidgin.vala
+++ b/tools/import-pidgin.vala
@@ -41,6 +41,33 @@ public class Folks.Importers.Pidgin : Folks.Importer
".purple", "blist.xml", null);
}
+ var file = File.new_for_path (filename);
+ if (!file.query_exists ())
+ {
+ throw new ImportError.MALFORMED_INPUT ("File %s does not exist.",
+ filename);
+ }
+
+ FileInfo file_info;
+ try
+ {
+ file_info = yield file.query_info_async (
+ FILE_ATTRIBUTE_ACCESS_CAN_READ, FileQueryInfoFlags.NONE,
+ Priority.DEFAULT);
+ }
+ catch (GLib.Error e)
+ {
+ throw new ImportError.MALFORMED_INPUT (
+ "Failed to get information about file %s: %s", filename,
+ e.message);
+ }
+
+ if (!file_info.get_attribute_boolean (FILE_ATTRIBUTE_ACCESS_CAN_READ))
+ {
+ throw new ImportError.MALFORMED_INPUT ("File %s is not readable.",
+ filename);
+ }
+
Xml.Doc* xml_doc = Parser.parse_file (filename);
if (xml_doc == null)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]