# HG changeset patch # User Chris Cannam # Date 1497861309 -3600 # Mon Jun 19 09:35:09 2017 +0100 # Node ID 807b55408d9e6bfc92bc80d937ef8fe370869d1d # Parent 3768bdde6fdf866aa63fff5bde8d9fa64a8979ef Catch exceptions by reference diff --git a/src/TransactionalStore.cpp b/src/TransactionalStore.cpp --- a/src/TransactionalStore.cpp +++ b/src/TransactionalStore.cpp @@ -297,7 +297,7 @@ DQ_DEBUG << "TransactionalStore::enterTransactionContext: replaying" << endl; try { m_store->change(cs); - } catch (RDFException &e) { + } catch (const RDFException &e) { throw RDFTransactionError(QString("Failed to enter transaction context. Has the store been modified non-transactionally while a transaction was in progress? Original error is: %1").arg(e.what())); } } @@ -321,7 +321,7 @@ if (!cs.empty()) { try { m_store->revert(cs); - } catch (RDFException &e) { + } catch (const RDFException &e) { throw RDFTransactionError(QString("Failed to leave transaction context. Has the store been modified non-transactionally while a transaction was in progress? Original error is: %1").arg(e.what())); } } @@ -370,7 +370,7 @@ } else { return false; } - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -404,7 +404,7 @@ } } return found; - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -456,7 +456,7 @@ check(); try { return m_td->contains(m_tx, t); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -466,7 +466,7 @@ check(); try { return m_td->match(m_tx, t); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -476,7 +476,7 @@ check(); try { return m_td->query(m_tx, sparql); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -486,7 +486,7 @@ check(); try { return m_td->complete(m_tx, t); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -496,7 +496,7 @@ check(); try { return m_td->matchOnce(m_tx, t); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -506,7 +506,7 @@ check(); try { return m_td->queryOnce(m_tx, sparql, bindingName); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -516,7 +516,7 @@ check(); try { return m_td->getUniqueUri(m_tx, prefix); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -526,7 +526,7 @@ check(); try { return m_td->addBlankNode(m_tx); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -540,7 +540,7 @@ check(); try { return m_td->save(m_tx, filename); - } catch (RDFException &) { + } catch (const RDFException &) { abandon(); throw; } @@ -562,7 +562,7 @@ } delete bs; bs = 0; - } catch (RDFException &) { + } catch (const RDFException &) { delete bs; abandon(); throw; diff --git a/src/backend/BasicStoreRedland.cpp b/src/backend/BasicStoreRedland.cpp --- a/src/backend/BasicStoreRedland.cpp +++ b/src/backend/BasicStoreRedland.cpp @@ -537,7 +537,7 @@ Uri quri; try { quri = lrdfUriToUri(uri); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { continue; } DQ_DEBUG << "namespace " << i << ": " << qpfx << " -> " << quri << endl; diff --git a/src/backend/BasicStoreSord.cpp b/src/backend/BasicStoreSord.cpp --- a/src/backend/BasicStoreSord.cpp +++ b/src/backend/BasicStoreSord.cpp @@ -446,7 +446,7 @@ d->addPrefixOnImport(qpfx, quri); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { } return SERD_SUCCESS; diff --git a/src/objectmapper/ObjectLoader.cpp b/src/objectmapper/ObjectLoader.cpp --- a/src/objectmapper/ObjectLoader.cpp +++ b/src/objectmapper/ObjectLoader.cpp @@ -498,7 +498,7 @@ DQ_DEBUG << "load: calling allocate(" << node << ")" << endl; try { allocate(state, node); - } catch (UnknownTypeException &e) { + } catch (const UnknownTypeException &e) { if (state.loadFlags & LoadState::IgnoreUnknownTypes) { DQ_DEBUG << "load: IgnoreUnknownTypes is set, removing object of unknown type and continuing" << endl; delete state.map.value(node); @@ -961,7 +961,7 @@ if (typeUri != Uri()) { try { className = m_tm.synthesiseClassForTypeUri(typeUri); - } catch (UnknownTypeException) { + } catch (const UnknownTypeException &) { DQ_DEBUG << "getClassNameForNode: Unknown type URI " << typeUri << endl; throw; } diff --git a/src/objectmapper/ObjectMapper.cpp b/src/objectmapper/ObjectMapper.cpp --- a/src/objectmapper/ObjectMapper.cpp +++ b/src/objectmapper/ObjectMapper.cpp @@ -178,7 +178,7 @@ QMutexLocker locker(&m_mutex); try { manage(o); - } catch (NoUriException) { + } catch (const NoUriException &) { // doesn't matter; it will be assigned one when mapped, // which will happen on the next commit because we are // adding it to the changed object map @@ -193,7 +193,7 @@ foreach (QObject *o, ol) { try { manage(o); - } catch (NoUriException) { + } catch (const NoUriException &) { // doesn't matter (as above) } } diff --git a/tests/TestBasicStore.h b/tests/TestBasicStore.h --- a/tests/TestBasicStore.h +++ b/tests/TestBasicStore.h @@ -70,28 +70,28 @@ try { Uri uri("/rdf/dataquay"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } try { Uri uri("#x"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } try { Uri uri("x"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } try { Uri uri(""); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } @@ -110,13 +110,13 @@ try { uri = Uri("blah:a"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } try { uri = Uri("blah:/a"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } @@ -128,7 +128,7 @@ try { uri = store.expand("bogus"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } @@ -139,7 +139,7 @@ try { uri = s1.expand(":relative"); QVERIFY(0); - } catch (RDFIncompleteURI &) { + } catch (const RDFIncompleteURI &) { QVERIFY(1); } } @@ -358,7 +358,7 @@ (Triple(store.expand(":fred"), anotherBlank, Node("this_statement_is_incomplete")))); - } catch (RDFException &) { + } catch (const RDFException &) { QVERIFY(1); } @@ -443,7 +443,7 @@ QCOMPARE(v.type, Node::URI); QCOMPARE(v.value, expected); - } catch (RDFUnsupportedError &e) { + } catch (const RDFUnsupportedError &e) { #if (QT_VERSION >= 0x050000) QSKIP("SPARQL queries not supported by current store backend"); #else @@ -482,7 +482,7 @@ store.expand("foaf:name"), Node("Alice Banquet"))); QVERIFY(0); - } catch (RDFException &) { + } catch (const RDFException &) { // can't complete a complete triple QVERIFY(1); } @@ -493,7 +493,7 @@ store.expand("foaf:name"), Node())); QVERIFY(0); - } catch (RDFException &) { + } catch (const RDFException &) { // can't complete an underspecified triple QVERIFY(1); } diff --git a/tests/TestImportOptions.h b/tests/TestImportOptions.h --- a/tests/TestImportOptions.h +++ b/tests/TestImportOptions.h @@ -107,7 +107,7 @@ bool caught = false; try { store.import(fileUrl, BasicStore::ImportFailOnDuplicates); - } catch (RDFDuplicateImportException) { + } catch (const RDFDuplicateImportException &) { caught = true; } QVERIFY2(caught, "Failed to catch RDFDuplicateImportException when importing duplicate graph with ImportFailOnDuplicates"); diff --git a/tests/TestObjectMapper.h b/tests/TestObjectMapper.h --- a/tests/TestObjectMapper.h +++ b/tests/TestObjectMapper.h @@ -198,7 +198,7 @@ // object type is not registered, this load should fail recalled = loader.load(uri); QVERIFY(0); - } catch (UnknownTypeException) { + } catch (const UnknownTypeException &) { QVERIFY(1); } @@ -227,7 +227,7 @@ // object type is not registered, this load should fail recalled = loader.load(uri); QVERIFY(0); - } catch (UnknownTypeException) { + } catch (const UnknownTypeException &) { QVERIFY(1); } @@ -457,7 +457,7 @@ // added, not just managed mapper.manage(a); QVERIFY(0); - } catch (NoUriException) { + } catch (const NoUriException &) { QVERIFY(1); } diff --git a/tests/TestTransactionalStore.h b/tests/TestTransactionalStore.h --- a/tests/TestTransactionalStore.h +++ b/tests/TestTransactionalStore.h @@ -120,7 +120,7 @@ Uri("http://xmlns.com/foaf/0.1/name"), Node("this_statement_is_incomplete"))); QVERIFY(0); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -130,14 +130,14 @@ store.expand(":is_sadly_deluded"), Node::fromVariant(true))); QVERIFY2(0, "add succeeded after auto-rollback, should have failed"); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } try { (void)t->match(Triple()); QVERIFY2(0, "match succeeded after auto-rollback, should have failed"); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -145,7 +145,7 @@ try { t->commit(); QVERIFY2(0, "commit succeeded after auto-rollback, should have failed"); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -153,7 +153,7 @@ try { t->rollback(); QVERIFY2(0, "rollback succeed after auto-rollback, should have failed"); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -192,7 +192,7 @@ Transaction *tt = ts->startTransaction(); QVERIFY(0); tt->rollback(); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } t->rollback(); @@ -220,7 +220,7 @@ Uri("http://xmlns.com/foaf/0.1/knows"), store.expand(":samuel")))); QVERIFY(0); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -233,7 +233,7 @@ try { Triples triples = t->match(Triple()); QVERIFY(0); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } @@ -244,7 +244,7 @@ try { t->commit(); QVERIFY(0); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } delete t; @@ -253,7 +253,7 @@ try { t->rollback(); QVERIFY(0); - } catch (RDFException) { + } catch (const RDFException &) { QVERIFY(1); } delete t; diff --git a/tests/tests.pro b/tests/tests.pro --- a/tests/tests.pro +++ b/tests/tests.pro @@ -1,6 +1,6 @@ TEMPLATE = app -CONFIG += debug console +CONFIG += debug console warn_on c++11 QT += testlib QT -= gui TARGET = test-dataquay