changeset 738:547b03533375 dataquay

Some exception handling
author Chris Cannam
date Fri, 25 May 2012 14:57:14 +0100
parents 403a8064aceb
children 51d3b8e816b8
files rdf/RDFImporter.cpp
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/rdf/RDFImporter.cpp	Fri May 25 14:17:27 2012 +0100
+++ b/rdf/RDFImporter.cpp	Fri May 25 14:57:14 2012 +0100
@@ -141,14 +141,17 @@
     m_store->addPrefix("event", Uri("http://purl.org/NET/c4dm/event.owl#"));
     m_store->addPrefix("rdfs", Uri("http://www.w3.org/2000/01/rdf-schema#"));
 
-    //!!! may throw!
-    QUrl url;
-    if (uri.startsWith("file:")) {
-        url = QUrl(uri);
-    } else {
-        url = QUrl::fromLocalFile(uri);
+    try {
+        QUrl url;
+        if (uri.startsWith("file:")) {
+            url = QUrl(uri);
+        } else {
+            url = QUrl::fromLocalFile(uri);
+        }
+        m_store->import(url, BasicStore::ImportIgnoreDuplicates);
+    } catch (std::exception &e) {
+        m_errorString = e.what();
     }
-    m_store->import(url, BasicStore::ImportIgnoreDuplicates);
 }
 
 RDFImporterImpl::~RDFImporterImpl()
@@ -811,11 +814,12 @@
     // This is not expected to return anything useful, but if it does
     // anything at all then we know we have RDF
     try {
-        //!!! non-local document? + may throw!!!
+        //!!! non-local document?
         store = BasicStore::load(QUrl(url));
         Triple t = store->matchOnce(Triple());
         if (t != Triple()) haveRDF = true;
-    } catch (...) {
+    } catch (std::exception &e) {
+        // nothing; haveRDF will be false so the next bit catches it
     }
 
     if (!haveRDF) {