From 9ab9cc78571c25f642546a7bf9f1bbe5387b262a Mon Sep 17 00:00:00 2001 From: Jan Date: Fri, 29 Mar 2019 15:59:37 +0100 Subject: [PATCH] disambiguate internal exceptions (#8623) --- arangod/Aql/AllRowsFetcher.h | 2 +- arangod/Aql/ConstFetcher.h | 2 +- arangod/Aql/MultiDependencySingleRowFetcher.h | 4 ++-- arangod/Aql/OptimizerRules.cpp | 2 +- arangod/Aql/SingleBlockFetcher.h | 2 +- arangod/Auth/UserManager.cpp | 2 +- arangod/Cluster/ClusterMethods.cpp | 2 +- arangod/ClusterEngine/ClusterCollection.cpp | 6 +++--- arangod/IResearch/IResearchExpressionContext.cpp | 2 +- arangod/Pregel/GraphStore.cpp | 7 +++---- arangod/Pregel/Worker.cpp | 2 +- arangod/RocksDBEngine/RocksDBCuckooIndexEstimator.h | 4 ++-- arangod/V8Server/v8-user-structures.cpp | 4 ++-- lib/Basics/Exceptions.cpp | 2 +- 14 files changed, 21 insertions(+), 22 deletions(-) diff --git a/arangod/Aql/AllRowsFetcher.h b/arangod/Aql/AllRowsFetcher.h index 9c83404004..ae24659c58 100644 --- a/arangod/Aql/AllRowsFetcher.h +++ b/arangod/Aql/AllRowsFetcher.h @@ -77,7 +77,7 @@ class AllRowsFetcher { // SingleRowFetcher instead. std::pair> fetchBlockForPassthrough(size_t) { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); }; /** diff --git a/arangod/Aql/ConstFetcher.h b/arangod/Aql/ConstFetcher.h index af8f7563e0..34875315e9 100644 --- a/arangod/Aql/ConstFetcher.h +++ b/arangod/Aql/ConstFetcher.h @@ -81,7 +81,7 @@ class ConstFetcher { std::pair preFetchNumberOfRows(size_t atMost) { // This is not implemented for this fetcher TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); } private: diff --git a/arangod/Aql/MultiDependencySingleRowFetcher.h b/arangod/Aql/MultiDependencySingleRowFetcher.h index 0cd56cae2e..39c347bd62 100644 --- a/arangod/Aql/MultiDependencySingleRowFetcher.h +++ b/arangod/Aql/MultiDependencySingleRowFetcher.h @@ -92,13 +92,13 @@ class MultiDependencySingleRowFetcher { std::pair fetchRow(size_t atMost = ExecutionBlock::DefaultBatchSize()) { // This is not implemented for this fetcher TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); } std::pair> fetchBlockForPassthrough(size_t atMost) { // This is not implemented for this fetcher TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); } std::pair preFetchNumberOfRows(size_t atMost) { diff --git a/arangod/Aql/OptimizerRules.cpp b/arangod/Aql/OptimizerRules.cpp index ab01076a44..581afe3c05 100644 --- a/arangod/Aql/OptimizerRules.cpp +++ b/arangod/Aql/OptimizerRules.cpp @@ -6603,7 +6603,7 @@ static std::unique_ptr buildGeoCondition(ExecutionPlan* plan, args->addMember(array); } else { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unsupported geo type"); } }; diff --git a/arangod/Aql/SingleBlockFetcher.h b/arangod/Aql/SingleBlockFetcher.h index 5c29e5ad54..9a56029d00 100644 --- a/arangod/Aql/SingleBlockFetcher.h +++ b/arangod/Aql/SingleBlockFetcher.h @@ -114,7 +114,7 @@ class SingleBlockFetcher { } std::pair> fetchBlockForPassthrough(size_t) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED); }; std::pair preFetchNumberOfRows(std::size_t) { diff --git a/arangod/Auth/UserManager.cpp b/arangod/Auth/UserManager.cpp index 3c62413e98..df775256eb 100644 --- a/arangod/Auth/UserManager.cpp +++ b/arangod/Auth/UserManager.cpp @@ -126,7 +126,7 @@ static std::shared_ptr QueryAllUsers(aql::QueryRegistry* queryRegi if (vocbase == nullptr) { LOG_TOPIC("b8c47", DEBUG, arangodb::Logger::AUTHENTICATION) << "system database is unknown"; - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "system database is unknown"); } // we cannot set this execution context, otherwise the transaction diff --git a/arangod/Cluster/ClusterMethods.cpp b/arangod/Cluster/ClusterMethods.cpp index 6064184d32..06cb6e015e 100644 --- a/arangod/Cluster/ClusterMethods.cpp +++ b/arangod/Cluster/ClusterMethods.cpp @@ -218,7 +218,7 @@ static void addTransactionHeaderForShard(transaction::Methods& trx, ClusterTrxMethods::addTransactionHeader(trx, leader, headers); } else { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "couldnt find shard in shardMap"); } } } // namespace diff --git a/arangod/ClusterEngine/ClusterCollection.cpp b/arangod/ClusterEngine/ClusterCollection.cpp index 6b3a996346..ac2b0ee3c2 100644 --- a/arangod/ClusterEngine/ClusterCollection.cpp +++ b/arangod/ClusterEngine/ClusterCollection.cpp @@ -93,7 +93,7 @@ ClusterCollection::ClusterCollection(LogicalCollection& collection, ClusterEngin } } else if (_engineType != ClusterEngineType::MockEngine) { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "invalid storage engine"); } } @@ -187,7 +187,7 @@ Result ClusterCollection::updateProperties(VPackSlice const& slice, bool doSync) } else if (_engineType != ClusterEngineType::MockEngine) { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "invalid storage engine"); } merge.close(); TRI_ASSERT(merge.slice().isObject()); @@ -244,7 +244,7 @@ void ClusterCollection::getPropertiesVPack(velocypack::Builder& result) const { } else if (_engineType != ClusterEngineType::MockEngine) { TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "invalid storage engine"); } } diff --git a/arangod/IResearch/IResearchExpressionContext.cpp b/arangod/IResearch/IResearchExpressionContext.cpp index acfdd77777..01371eda5f 100644 --- a/arangod/IResearch/IResearchExpressionContext.cpp +++ b/arangod/IResearch/IResearchExpressionContext.cpp @@ -75,7 +75,7 @@ AqlValue ViewExpressionContext::getVariableValue(Variable const* var, bool doCop auto const it = vars.find(var->id); if (vars.end() == it) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "cannot find variable"); } auto const& varInfo = it->second; diff --git a/arangod/Pregel/GraphStore.cpp b/arangod/Pregel/GraphStore.cpp index c8c1f00d51..36f7b3b58f 100644 --- a/arangod/Pregel/GraphStore.cpp +++ b/arangod/Pregel/GraphStore.cpp @@ -449,11 +449,10 @@ void GraphStore::_loadEdges(transaction::Methods& trx, ShardID const& edge // If this is called from loadDocument we didn't preallocate the vector if (_edges->size() <= offset) { if (!_config->lazyLoading()) { - LOG_TOPIC("9d0e6", ERR, Logger::PREGEL) << "Pregel did not preallocate enough " - << "space for all edges. This hints " - << "at a bug with collection count()"; + std::string msg = "Pregel did not preallocate enough space for all edges. This hints at a bug with collection count()"; + LOG_TOPIC("9d0e6", ERR, Logger::PREGEL) << msg; TRI_ASSERT(false); - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, msg); } // lazy loading always uses vector backed storage ((VectorTypedBuffer>*)_edges)->appendEmptyElement(); diff --git a/arangod/Pregel/Worker.cpp b/arangod/Pregel/Worker.cpp index b5ea12adf6..305dfc4b02 100644 --- a/arangod/Pregel/Worker.cpp +++ b/arangod/Pregel/Worker.cpp @@ -180,7 +180,7 @@ void Worker::prepareGlobalStep(VPackSlice const& data, VPackBuilder& re if (_state != WorkerState::IDLE) { LOG_TOPIC("b8506", ERR, Logger::PREGEL) << "Cannot prepare a gss when the worker is not idle"; - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "Cannot prepare a gss when the worker is not idle"); } _state = WorkerState::PREPARING; // stop any running step LOG_TOPIC("f16f2", DEBUG, Logger::PREGEL) << "Received prepare GSS: " << data.toJson(); diff --git a/arangod/RocksDBEngine/RocksDBCuckooIndexEstimator.h b/arangod/RocksDBEngine/RocksDBCuckooIndexEstimator.h index 34ac53fa62..b962df6659 100644 --- a/arangod/RocksDBEngine/RocksDBCuckooIndexEstimator.h +++ b/arangod/RocksDBEngine/RocksDBCuckooIndexEstimator.h @@ -216,7 +216,7 @@ class RocksDBCuckooIndexEstimator { LOG_TOPIC("bcd09", WARN, arangodb::Logger::ENGINES) << "unable to restore index estimates: invalid format found"; // Do not construct from serialization, use other constructor instead - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unable to restore index estimates: invalid format found"); } } } @@ -809,7 +809,7 @@ class RocksDBCuckooIndexEstimator { current += sizeof(uint64_t); if (_size <= 256) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unable to unserialize index estimates"); } _nrUsed = rocksutils::uint64FromPersistent(current); diff --git a/arangod/V8Server/v8-user-structures.cpp b/arangod/V8Server/v8-user-structures.cpp index a2bbe07069..476ade7d5a 100644 --- a/arangod/V8Server/v8-user-structures.cpp +++ b/arangod/V8Server/v8-user-structures.cpp @@ -1976,13 +1976,13 @@ void TRI_ExpireFoxxQueueDatabaseCache(TRI_vocbase_t* vocbase) { auto hash = GetKeySpace(vocbase, name); if (hash == nullptr) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unable to find keyspace"); } result = hash->keySet(key, 0); } if (!result) { - THROW_ARANGO_EXCEPTION(TRI_ERROR_INTERNAL); + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "unable to set key"); } } diff --git a/lib/Basics/Exceptions.cpp b/lib/Basics/Exceptions.cpp index c9babb410f..7d0a476d18 100644 --- a/lib/Basics/Exceptions.cpp +++ b/lib/Basics/Exceptions.cpp @@ -98,7 +98,7 @@ void Exception::appendLocation() noexcept { _errorMessage += std::string(" (exception location: ") + _file + ":" + std::to_string(_line) + "). Please report this error to arangodb.com"; - } else if (_code == TRI_ERROR_OUT_OF_MEMORY) { + } else if (_code == TRI_ERROR_OUT_OF_MEMORY || _code == TRI_ERROR_NOT_IMPLEMENTED) { _errorMessage += std::string(" (exception location: ") + _file + ":" + std::to_string(_line) + ")"; }