comparison rdf/RDFImporter.cpp @ 738:547b03533375 dataquay

Some exception handling
author Chris Cannam
date Fri, 25 May 2012 14:57:14 +0100
parents 31ab733841d0
children e802e550a1f2
comparison
equal deleted inserted replaced
737:403a8064aceb 738:547b03533375
139 m_store->addPrefix("dc", Uri("http://purl.org/dc/elements/1.1/")); 139 m_store->addPrefix("dc", Uri("http://purl.org/dc/elements/1.1/"));
140 m_store->addPrefix("tl", Uri("http://purl.org/NET/c4dm/timeline.owl#")); 140 m_store->addPrefix("tl", Uri("http://purl.org/NET/c4dm/timeline.owl#"));
141 m_store->addPrefix("event", Uri("http://purl.org/NET/c4dm/event.owl#")); 141 m_store->addPrefix("event", Uri("http://purl.org/NET/c4dm/event.owl#"));
142 m_store->addPrefix("rdfs", Uri("http://www.w3.org/2000/01/rdf-schema#")); 142 m_store->addPrefix("rdfs", Uri("http://www.w3.org/2000/01/rdf-schema#"));
143 143
144 //!!! may throw! 144 try {
145 QUrl url; 145 QUrl url;
146 if (uri.startsWith("file:")) { 146 if (uri.startsWith("file:")) {
147 url = QUrl(uri); 147 url = QUrl(uri);
148 } else { 148 } else {
149 url = QUrl::fromLocalFile(uri); 149 url = QUrl::fromLocalFile(uri);
150 } 150 }
151 m_store->import(url, BasicStore::ImportIgnoreDuplicates); 151 m_store->import(url, BasicStore::ImportIgnoreDuplicates);
152 } catch (std::exception &e) {
153 m_errorString = e.what();
154 }
152 } 155 }
153 156
154 RDFImporterImpl::~RDFImporterImpl() 157 RDFImporterImpl::~RDFImporterImpl()
155 { 158 {
156 delete m_store; 159 delete m_store;
809 BasicStore *store = 0; 812 BasicStore *store = 0;
810 813
811 // This is not expected to return anything useful, but if it does 814 // This is not expected to return anything useful, but if it does
812 // anything at all then we know we have RDF 815 // anything at all then we know we have RDF
813 try { 816 try {
814 //!!! non-local document? + may throw!!! 817 //!!! non-local document?
815 store = BasicStore::load(QUrl(url)); 818 store = BasicStore::load(QUrl(url));
816 Triple t = store->matchOnce(Triple()); 819 Triple t = store->matchOnce(Triple());
817 if (t != Triple()) haveRDF = true; 820 if (t != Triple()) haveRDF = true;
818 } catch (...) { 821 } catch (std::exception &e) {
822 // nothing; haveRDF will be false so the next bit catches it
819 } 823 }
820 824
821 if (!haveRDF) { 825 if (!haveRDF) {
822 delete store; 826 delete store;
823 return NotRDF; 827 return NotRDF;