mirror of https://gitee.com/bigwinds/arangodb
merged Exceptions.h and Exception.h
This commit is contained in:
parent
dc860ef976
commit
4c5d57f1b8
|
@ -32,7 +32,7 @@
|
|||
#include "Aql/Collection.h"
|
||||
#include "Aql/Executor.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/collection.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
#define ARANGODB_AQL_ASTNODE_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/vector.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Aql/Query.h"
|
||||
|
||||
namespace triagens {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "Aql/BindParameters.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
||||
|
|
|
@ -30,10 +30,10 @@
|
|||
#include "Collection.h"
|
||||
#include "Aql/ExecutionEngine.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Cluster/ClusterInfo.h"
|
||||
#include "Cluster/ClusterMethods.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#define ARANGODB_AQL_COLLECTIONS_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Aql/Collection.h"
|
||||
#include "Utils/Exception.h"
|
||||
|
||||
struct TRI_vocbase_s;
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/StringBuffer.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "HashIndex/hash-index.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "V8/v8-globals.h"
|
||||
#include "VocBase/edge-collection.h"
|
||||
#include "VocBase/index.h"
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "Aql/QueryRegistry.h"
|
||||
#include "Aql/WalkerWorker.h"
|
||||
#include "Cluster/ClusterComm.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/logging.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "Aql/Variable.h"
|
||||
#include "Aql/WalkerWorker.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
using namespace triagens::basics;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Aql/ExecutionStats.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
using Json = triagens::basics::Json;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include "Aql/V8Expression.h"
|
||||
#include "Aql/Variable.h"
|
||||
#include "Basics/StringBuffer.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "V8/v8-conv.h"
|
||||
#include "V8/v8-globals.h"
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "Basics/json.h"
|
||||
#include "ShapedJson/shaped-json.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
using Json = triagens::basics::Json;
|
||||
|
@ -169,7 +169,7 @@ AqlValue Expression::execute (triagens::arango::AqlTransaction* trx,
|
|||
// std::cout << triagens::basics::Json(TRI_UNKNOWN_MEM_ZONE, _node->toJson(TRI_UNKNOWN_MEM_ZONE, true)).toString()<< "\n";
|
||||
return _func->execute(isolate, _ast->query(), trx, docColls, argv, startPos, vars, regs);
|
||||
}
|
||||
catch (triagens::arango::Exception& ex) {
|
||||
catch (triagens::basics::Exception& ex) {
|
||||
if (_ast->query()->verboseErrors()) {
|
||||
ex.addToMessage(" while evaluating expression ");
|
||||
auto json = _node->toJson(TRI_UNKNOWN_MEM_ZONE, false);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Aql/Function.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "Aql/Functions.h"
|
||||
#include "Basics/fpconv.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
using Json = triagens::basics::Json;
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
#define ARANGODB_AQL_INDEX_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "HashIndex/hash-index.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/index.h"
|
||||
|
||||
namespace triagens {
|
||||
|
|
|
@ -38,10 +38,10 @@
|
|||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Utils/AqlTransaction.h"
|
||||
#include "Utils/CollectionNameResolver.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Utils/StandaloneTransactionContext.h"
|
||||
#include "Utils/V8TransactionContext.h"
|
||||
#include "V8Server/ApplicationV8.h"
|
||||
|
@ -597,7 +597,7 @@ QueryResult Query::prepare (QueryRegistry* registry) {
|
|||
_engine = engine;
|
||||
return QueryResult();
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
cleanupPlanAndEngine(ex.code());
|
||||
return QueryResult(ex.code(), ex.message() + getStateString());
|
||||
}
|
||||
|
@ -667,7 +667,7 @@ QueryResult Query::execute (QueryRegistry* registry) {
|
|||
|
||||
return result;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
cleanupPlanAndEngine(ex.code());
|
||||
return QueryResult(ex.code(), ex.message() + getStateString());
|
||||
}
|
||||
|
@ -739,7 +739,7 @@ QueryResultV8 Query::executeV8 (v8::Isolate* isolate, QueryRegistry* registry) {
|
|||
|
||||
return result;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
cleanupPlanAndEngine(ex.code());
|
||||
return QueryResultV8(ex.code(), ex.message() + getStateString());
|
||||
}
|
||||
|
@ -766,7 +766,7 @@ QueryResult Query::parse () {
|
|||
Parser parser(this);
|
||||
return parser.parse(true);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return QueryResult(ex.code(), ex.message());
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -854,7 +854,7 @@ QueryResult Query::explain () {
|
|||
|
||||
return result;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return QueryResult(ex.code(), ex.message() + getStateString());
|
||||
}
|
||||
catch (std::bad_alloc const&) {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "Basics/logging.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
|
|
@ -434,7 +434,7 @@ void RestAqlHandler::useQuery (std::string const& operation,
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
_queryRegistry->close(_vocbase, _qId);
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
ex.code(),
|
||||
|
@ -549,7 +549,7 @@ void RestAqlHandler::getInfoQuery (std::string const& operation,
|
|||
return;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
_queryRegistry->close(_vocbase, _qId);
|
||||
LOG_ERROR("failed during use of query: %s", ex.message().c_str());
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Aql/Scopes.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Utils/Exception.h"
|
||||
#include "Aql/VariableGenerator.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
using namespace triagens::aql;
|
||||
using Json = triagens::basics::Json;
|
||||
|
|
|
@ -115,7 +115,6 @@ add_executable(
|
|||
RestServer/arangod.cpp
|
||||
SkipLists/skiplistIndex.cpp
|
||||
Utils/DocumentHelper.cpp
|
||||
Utils/Exception.cpp
|
||||
Utils/StandaloneTransactionContext.cpp
|
||||
Utils/Transaction.cpp
|
||||
Utils/TransactionContext.cpp
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/headers.h"
|
||||
|
|
|
@ -89,7 +89,6 @@ arangod_libarangod_a_SOURCES = \
|
|||
arangod/RestServer/arangod.cpp \
|
||||
arangod/SkipLists/skiplistIndex.cpp \
|
||||
arangod/Utils/DocumentHelper.cpp \
|
||||
arangod/Utils/Exception.cpp \
|
||||
arangod/Utils/StandaloneTransactionContext.cpp \
|
||||
arangod/Utils/Transaction.cpp \
|
||||
arangod/Utils/TransactionContext.cpp \
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "ContinuousSyncer.h"
|
||||
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/StringBuffer.h"
|
||||
|
@ -38,7 +39,6 @@
|
|||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/transaction.h"
|
||||
|
@ -647,7 +647,7 @@ int ContinuousSyncer::changeCollection (TRI_json_t const* json) {
|
|||
bool doSync = _vocbase->_settings.forceSyncProperties;
|
||||
return TRI_UpdateCollectionInfo(_vocbase, guard.collection()->_collection, ¶meters, doSync);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
#include "InitialSyncer.h"
|
||||
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/json.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
|
@ -37,7 +38,6 @@
|
|||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/index.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
|
@ -858,7 +858,7 @@ int InitialSyncer::handleCollection (TRI_json_t const* parameters,
|
|||
TRI_WRITE_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(document);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
#include "Basics/json.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
#include "SimpleHttpClient/GeneralClientConnection.h"
|
||||
#include "SimpleHttpClient/SimpleHttpClient.h"
|
||||
#include "SimpleHttpClient/SimpleHttpResult.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "Utils/DocumentHelper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
|
@ -291,7 +291,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
|
|||
|
||||
return res;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -313,7 +313,7 @@ int Syncer::applyCollectionDumpMarker (TRI_transaction_collection_t* trxCollecti
|
|||
res = TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -501,7 +501,7 @@ int Syncer::createIndex (TRI_json_t const* json) {
|
|||
|
||||
return res;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -542,7 +542,7 @@ int Syncer::dropIndex (TRI_json_t const* json) {
|
|||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -83,7 +83,14 @@ HttpHandler::status_t RestPleaseUpgradeHandler::execute () {
|
|||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestPleaseUpgradeHandler::handleError (TriagensError const&) {
|
||||
void RestPleaseUpgradeHandler::handleError (const TriagensError&) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestPleaseUpgradeHandler::handleError (const Exception&) {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -81,7 +81,13 @@ namespace triagens {
|
|||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleError (basics::TriagensError const&);
|
||||
void handleError (const basics::TriagensError&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleError (const basics::Exception&);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,6 +132,9 @@ bool RestQueryHandler::readQueryProperties () {
|
|||
catch (const TriagensError& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (const Exception& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
triagens::basics::InternalError err(ex, __FILE__, __LINE__);
|
||||
handleError(err);
|
||||
|
@ -174,6 +177,9 @@ bool RestQueryHandler::readQuery (bool slow) {
|
|||
catch (const TriagensError& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (const Exception& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
triagens::basics::InternalError err(ex, __FILE__, __LINE__);
|
||||
handleError(err);
|
||||
|
@ -197,7 +203,7 @@ bool RestQueryHandler::readQuery () {
|
|||
generateError(HttpResponse::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||
"expecting GET /_api/query/<type>");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& name = suffix[0];
|
||||
|
@ -215,7 +221,7 @@ bool RestQueryHandler::readQuery () {
|
|||
generateError(HttpResponse::NOT_FOUND,
|
||||
TRI_ERROR_HTTP_NOT_FOUND,
|
||||
"unknown type '" + name + "', expecting 'slow', 'current', or 'properties'");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -276,7 +282,7 @@ bool RestQueryHandler::deleteQuery () {
|
|||
generateError(HttpResponse::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||
"expecting DELETE /_api/query/<id> or /_api/query/slow");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& name = suffix[0];
|
||||
|
@ -300,16 +306,14 @@ bool RestQueryHandler::replaceProperties () {
|
|||
generateError(HttpResponse::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||
"expecting PUT /_api/query/properties");
|
||||
return false;
|
||||
}
|
||||
|
||||
TRI_json_t* json = parseJsonBody();
|
||||
|
||||
if (json == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (JsonHelper::isObject(json)) {
|
||||
unique_ptr<TRI_json_t> body(parseJsonBody());
|
||||
|
||||
if (body == nullptr) {
|
||||
// error message generated in parseJsonBody
|
||||
return true;
|
||||
}
|
||||
|
||||
auto queryList = static_cast<triagens::aql::QueryList*>(_vocbase->_queries);
|
||||
|
@ -323,24 +327,24 @@ bool RestQueryHandler::replaceProperties () {
|
|||
|
||||
// TODO(fc) add a "hasSomething" to JsonHelper?
|
||||
|
||||
if (JsonHelper::getObjectElement(json, "enabled") != nullptr) {
|
||||
enabled = JsonHelper::checkAndGetBooleanValue(json, "enabled");
|
||||
if (JsonHelper::getObjectElement(body.get(), "enabled") != nullptr) {
|
||||
enabled = JsonHelper::checkAndGetBooleanValue(body.get(), "enabled");
|
||||
}
|
||||
|
||||
if (JsonHelper::getObjectElement(json, "trackSlowQueries") != nullptr) {
|
||||
trackSlowQueries = JsonHelper::checkAndGetBooleanValue(json, "trackSlowQueries");
|
||||
if (JsonHelper::getObjectElement(body.get(), "trackSlowQueries") != nullptr) {
|
||||
trackSlowQueries = JsonHelper::checkAndGetBooleanValue(body.get(), "trackSlowQueries");
|
||||
}
|
||||
|
||||
if (JsonHelper::getObjectElement(json, "maxSlowQueries") != nullptr) {
|
||||
maxSlowQueries = JsonHelper::checkAndGetNumericValue<size_t>(json, "maxSlowQueries");
|
||||
if (JsonHelper::getObjectElement(body.get(), "maxSlowQueries") != nullptr) {
|
||||
maxSlowQueries = JsonHelper::checkAndGetNumericValue<size_t>(body.get(), "maxSlowQueries");
|
||||
}
|
||||
|
||||
if (JsonHelper::getObjectElement(json, "slowQueryThreshold") != nullptr) {
|
||||
slowQueryThreshold = JsonHelper::checkAndGetNumericValue<double>(json, "slowQueryThreshold");
|
||||
if (JsonHelper::getObjectElement(body.get(), "slowQueryThreshold") != nullptr) {
|
||||
slowQueryThreshold = JsonHelper::checkAndGetNumericValue<double>(body.get(), "slowQueryThreshold");
|
||||
}
|
||||
|
||||
if (JsonHelper::getObjectElement(json, "maxQueryStringLength") != nullptr) {
|
||||
maxQueryStringLength = JsonHelper::checkAndGetNumericValue<size_t>(json, "maxQueryStringLength");
|
||||
if (JsonHelper::getObjectElement(body.get(), "maxQueryStringLength") != nullptr) {
|
||||
maxQueryStringLength = JsonHelper::checkAndGetNumericValue<size_t>(body.get(), "maxQueryStringLength");
|
||||
}
|
||||
|
||||
queryList->enabled(enabled);
|
||||
|
@ -354,6 +358,9 @@ bool RestQueryHandler::replaceProperties () {
|
|||
catch (const TriagensError& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (const Exception& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
triagens::basics::InternalError err(ex, __FILE__, __LINE__);
|
||||
handleError(err);
|
||||
|
@ -377,18 +384,18 @@ bool RestQueryHandler::parseQuery () {
|
|||
generateError(HttpResponse::BAD,
|
||||
TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||
"expecting POST /_api/query");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
TRI_json_t* body = parseJsonBody();
|
||||
unique_ptr<TRI_json_t> body(parseJsonBody());
|
||||
|
||||
if (body == nullptr) {
|
||||
TRI_FreeJson(TRI_CORE_MEM_ZONE, body);
|
||||
if (body.get() == nullptr) {
|
||||
// error message generated in parseJsonBody
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
const string&& queryString = JsonHelper::checkAndGetStringValue(body, "query");
|
||||
const string&& queryString = JsonHelper::checkAndGetStringValue(body.get(), "query");
|
||||
|
||||
Query query(_applicationV8, true, _vocbase, queryString.c_str(), queryString.size(), nullptr, nullptr, PART_MAIN);
|
||||
|
||||
|
@ -435,6 +442,9 @@ bool RestQueryHandler::parseQuery () {
|
|||
catch (const TriagensError& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (const Exception& err) {
|
||||
handleError(err);
|
||||
}
|
||||
catch (std::exception const& ex) {
|
||||
triagens::basics::InternalError err(ex, __FILE__, __LINE__);
|
||||
handleError(err);
|
||||
|
|
|
@ -1073,7 +1073,7 @@ void RestReplicationHandler::handleCommandLoggerFollow () {
|
|||
insertClient(dump._lastFoundTick);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1987,7 +1987,7 @@ int RestReplicationHandler::processRestoreIndexes (TRI_json_t const* collection,
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
errorMsg = "could not create index: " + string(TRI_errno_string(ex.code()));
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -2161,7 +2161,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
|
|||
|
||||
return res;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
TRI_FreeShapedJson(zone, shaped);
|
||||
return ex.code();
|
||||
}
|
||||
|
@ -2186,7 +2186,7 @@ int RestReplicationHandler::applyCollectionDumpMarker (CollectionNameResolver co
|
|||
res = TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -2960,7 +2960,7 @@ void RestReplicationHandler::handleCommandDump () {
|
|||
// avoid double freeing
|
||||
TRI_StealStringBuffer(dump._buffer);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define ARANGODB_UTILS_COLLECTION_GUARD_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
||||
namespace triagens {
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define ARANGODB_UTILS_DATABASE_GUARD_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/server.h"
|
||||
|
||||
struct TRI_vocbase_s;
|
||||
|
|
|
@ -1,188 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango exceptions
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2009-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Exception.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace triagens::arango;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief controls if backtraces are printed with exceptions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool WithBackTrace = false;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor, without format string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::Exception (int code,
|
||||
char const* file,
|
||||
int line)
|
||||
: _errorMessage(TRI_errno_string(code)),
|
||||
_file(file),
|
||||
_line(line),
|
||||
_code(code) {
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
#if HAVE_BACKTRACE
|
||||
if (WithBackTrace) {
|
||||
_errorMessage += std::string("\n\n");
|
||||
TRI_GetBacktrace(_errorMessage);
|
||||
_errorMessage += std::string("\n\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor, for creating an exception with an already created
|
||||
/// error message (normally based on error templates containing %s, %d etc.)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::Exception (int code,
|
||||
string const& errorMessage,
|
||||
char const* file,
|
||||
int line)
|
||||
: _errorMessage(errorMessage),
|
||||
_file(file),
|
||||
_line(line),
|
||||
_code(code) {
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
#if HAVE_BACKTRACE
|
||||
if (WithBackTrace) {
|
||||
_errorMessage += std::string("\n\n");
|
||||
TRI_GetBacktrace(_errorMessage);
|
||||
_errorMessage += std::string("\n\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::~Exception () throw () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return exception message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char const* Exception::what () const throw () {
|
||||
// we have to use an instance member here because we should not return a
|
||||
// pointer (c_str()) to the internals of a stack object (stack object will
|
||||
// be destroyed when function is left...)
|
||||
// additionally, we should not create new string values here as this might
|
||||
// throw exceptions - but this function is marked to throw no exceptions!
|
||||
/*
|
||||
std::string message = "exception in '";
|
||||
message.append(_file);
|
||||
message.append("' at line ");
|
||||
message.append(basics::StringUtils::itoa(_line));
|
||||
message.append(": ");
|
||||
message += this->message();
|
||||
|
||||
return message.c_str();
|
||||
*/
|
||||
|
||||
return _errorMessage.c_str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief construct an error message from a template string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string Exception::FillExceptionString (int code,
|
||||
...) {
|
||||
char const* format = TRI_errno_string(code);
|
||||
TRI_ASSERT(format != nullptr);
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// Obviously the formatstring of the error code has to support parameters.
|
||||
TRI_ASSERT(strchr(format, '%') != nullptr);
|
||||
#endif
|
||||
|
||||
char buffer[1024];
|
||||
va_list ap;
|
||||
va_start(ap, code);
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1] = '\0'; // Windows
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief construct an error message from a template string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string Exception::FillFormatExceptionString (char const* format,
|
||||
...) {
|
||||
TRI_ASSERT(format != nullptr);
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// Format #1 should come from the macro...
|
||||
TRI_ASSERT(strchr(format, '%') != nullptr);
|
||||
// Obviously the user has to give us a format string.
|
||||
TRI_ASSERT(strchr(strchr(format, '%'), '%') != nullptr);
|
||||
#endif
|
||||
|
||||
char buffer[1024];
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1] = '\0'; // Windows
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief controls whether a backtrace is created for each exception
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Exception::SetVerbose (bool verbose) {
|
||||
WithBackTrace = verbose;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -1,151 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango exceptions
|
||||
///
|
||||
/// @file
|
||||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
/// you may not use this file except in compliance with the License.
|
||||
/// You may obtain a copy of the License at
|
||||
///
|
||||
/// http://www.apache.org/licenses/LICENSE-2.0
|
||||
///
|
||||
/// Unless required by applicable law or agreed to in writing, software
|
||||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
/// See the License for the specific language governing permissions and
|
||||
/// limitations under the License.
|
||||
///
|
||||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2009-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef ARANGODB_UTILS_EXCEPTION_H
|
||||
#define ARANGODB_UTILS_EXCEPTION_H 1
|
||||
|
||||
#include "Basics/Common.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public macros
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION(code) \
|
||||
throw triagens::arango::Exception(code, __FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and arbitrary
|
||||
/// arguments (to be inserted in printf-style manner)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_PARAMS(code, ...) \
|
||||
throw triagens::arango::Exception(code, triagens::arango::Exception::FillExceptionString(code, __VA_ARGS__), __FILE__, __LINE__)
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and arbitrary
|
||||
/// arguments (to be inserted in printf-style manner)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_FORMAT(code, format, ...) \
|
||||
throw triagens::arango::Exception(code, \
|
||||
triagens::arango::Exception::FillFormatExceptionString( \
|
||||
"%s: " format,\
|
||||
TRI_errno_string(code), \
|
||||
__VA_ARGS__),\
|
||||
__FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and an already-built
|
||||
/// error message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_MESSAGE(code, message) \
|
||||
throw triagens::arango::Exception(code, message, __FILE__, __LINE__)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace triagens {
|
||||
namespace arango {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango exception type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Exception : public virtual std::exception {
|
||||
|
||||
public:
|
||||
|
||||
Exception (int code,
|
||||
char const* file,
|
||||
int line);
|
||||
|
||||
Exception (int code,
|
||||
std::string const& errorMessage,
|
||||
char const* file,
|
||||
int line);
|
||||
|
||||
~Exception () throw ();
|
||||
|
||||
public:
|
||||
|
||||
char const * what () const throw ();
|
||||
|
||||
std::string message () const throw () {
|
||||
return _errorMessage;
|
||||
}
|
||||
|
||||
int code () const throw () {
|
||||
return _code;
|
||||
}
|
||||
|
||||
void addToMessage(std::string More) {
|
||||
_errorMessage += More;
|
||||
}
|
||||
|
||||
static std::string FillExceptionString (int, ...);
|
||||
static std::string FillFormatExceptionString (char const * format,
|
||||
...);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief controls whether a backtrace is created for each exception
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void SetVerbose (bool);
|
||||
|
||||
protected:
|
||||
std::string _errorMessage;
|
||||
char const* _file;
|
||||
int const _line;
|
||||
int const _code;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @page\\|// --SECTION--\\|/// @\\}"
|
||||
// End:
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#include "Cluster/ServerState.h"
|
||||
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/barrier.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
|
@ -542,7 +542,7 @@ namespace triagens {
|
|||
! isLocked(trxCollection, TRI_TRANSACTION_WRITE),
|
||||
forceSync);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -648,7 +648,7 @@ namespace triagens {
|
|||
mptr,
|
||||
! isLocked(trxCollection, TRI_TRANSACTION_READ));
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1179,7 +1179,7 @@ namespace triagens {
|
|||
forceSync,
|
||||
false);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1218,7 +1218,7 @@ namespace triagens {
|
|||
! isLocked(trxCollection, TRI_TRANSACTION_WRITE),
|
||||
forceSync);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1270,7 +1270,7 @@ namespace triagens {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -2257,7 +2257,7 @@ static void JS_PropertiesVocbaseCol (const v8::FunctionCallbackInfo<v8::Value>&
|
|||
THROW_ARANGO_EXCEPTION(slotInfo.errorCode);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "v8-user-structures.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Basics/ReadWriteLock.h"
|
||||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
|
@ -35,7 +36,6 @@
|
|||
#include "Basics/json.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
#include "V8/v8-conv.h"
|
||||
#include "V8/v8-utils.h"
|
||||
|
|
|
@ -582,7 +582,7 @@ static void JS_EnableNativeBacktraces (const v8::FunctionCallbackInfo<v8::Value>
|
|||
TRI_V8_THROW_EXCEPTION_USAGE("ENABLE_NATIVE_BACKTRACES(<value>)");
|
||||
}
|
||||
|
||||
triagens::arango::Exception::SetVerbose(TRI_ObjectToBoolean(args[0]));
|
||||
triagens::basics::Exception::SetVerbose(TRI_ObjectToBoolean(args[0]));
|
||||
|
||||
TRI_V8_RETURN_UNDEFINED();
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "Basics/logging.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/ThreadPool.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "CapConstraint/cap-constraint.h"
|
||||
#include "FulltextIndex/fulltext-index.h"
|
||||
#include "GeoIndex/geo-index.h"
|
||||
|
@ -44,7 +45,6 @@
|
|||
#include "Utils/transactions.h"
|
||||
#include "Utils/CollectionReadLocker.h"
|
||||
#include "Utils/CollectionWriteLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/edge-collection.h"
|
||||
#include "VocBase/index.h"
|
||||
#include "VocBase/key-generator.h"
|
||||
|
@ -3505,7 +3505,7 @@ bool TRI_DropIndexDocumentCollection (TRI_document_collection_t* document,
|
|||
|
||||
return true;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "Basics/fasthash.h"
|
||||
#include "Basics/json-utilities.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "CapConstraint/cap-constraint.h"
|
||||
#include "FulltextIndex/fulltext-index.h"
|
||||
#include "FulltextIndex/fulltext-wordlist.h"
|
||||
|
@ -46,7 +47,6 @@
|
|||
#include "HashIndex/hash-index.h"
|
||||
#include "ShapedJson/shape-accessor.h"
|
||||
#include "ShapedJson/shaped-json.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/edge-collection.h"
|
||||
#include "VocBase/server.h"
|
||||
|
@ -386,7 +386,7 @@ int TRI_SaveIndex (TRI_document_collection_t* document,
|
|||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -1442,7 +1442,7 @@ int TRI_DumpLogReplication (TRI_replication_dump_t* dump,
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
|
||||
#include "Basics/associative.h"
|
||||
#include "Basics/string-buffer.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "ShapedJson/shaped-json.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/replication-common.h"
|
||||
#include "VocBase/voc-types.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
#include "Basics/random.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/JsonHelper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/auth.h"
|
||||
#include "VocBase/replication-applier.h"
|
||||
#include "VocBase/vocbase.h"
|
||||
|
@ -1503,7 +1503,7 @@ static int WriteCreateMarker (TRI_voc_tick_t id,
|
|||
THROW_ARANGO_EXCEPTION(slotInfo.errorCode);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1533,7 +1533,7 @@ static int WriteDropMarker (TRI_voc_tick_t id) {
|
|||
THROW_ARANGO_EXCEPTION(slotInfo.errorCode);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
#include "Basics/conversions.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/server.h"
|
||||
|
@ -648,7 +647,7 @@ static int WriteBeginMarker (TRI_transaction_t* trx) {
|
|||
trx->_beginWritten = true;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -695,7 +694,7 @@ static int WriteAbortMarker (TRI_transaction_t* trx) {
|
|||
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -738,7 +737,7 @@ static int WriteCommitMarker (TRI_transaction_t* trx) {
|
|||
res = GetLogfileManager()->allocateAndWrite(marker, false).errorCode;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "Basics/logging.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/utf8-helper.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
|
@ -218,7 +218,7 @@ static TRI_shape_aid_t FindOrCreateAttributeByName (TRI_shaper_t* shaper,
|
|||
|
||||
return aid;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -387,7 +387,7 @@ static TRI_shape_t const* FindShape (TRI_shaper_t* shaper,
|
|||
TRI_Free(TRI_UNKNOWN_MEM_ZONE, shape);
|
||||
return result;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -45,8 +45,7 @@
|
|||
#include "Basics/random.h"
|
||||
#include "Basics/tri-strings.h"
|
||||
#include "Basics/threads.h"
|
||||
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/auth.h"
|
||||
#include "VocBase/barrier.h"
|
||||
|
@ -182,7 +181,7 @@ static int WriteDropCollectionMarker (TRI_vocbase_t* vocbase,
|
|||
THROW_ARANGO_EXCEPTION(slotInfo.errorCode);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -682,7 +681,7 @@ static TRI_vocbase_col_t* CreateCollection (TRI_vocbase_t* vocbase,
|
|||
TRI_FreeJson(TRI_CORE_MEM_ZONE, json);
|
||||
return collection;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -833,7 +832,7 @@ static int RenameCollection (TRI_vocbase_t* vocbase,
|
|||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "AllocatorThread.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
using namespace triagens::wal;
|
||||
|
@ -157,7 +157,7 @@ void AllocatorThread::run () {
|
|||
LOG_ERROR("unable to create new WAL reserve logfile");
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
int res = ex.code();
|
||||
LOG_ERROR("got unexpected error in allocatorThread: %s", TRI_errno_string(res));
|
||||
}
|
||||
|
|
|
@ -28,13 +28,14 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "CollectorThread.h"
|
||||
|
||||
#include "Basics/MutexLocker.h"
|
||||
#include "Basics/hashes.h"
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Utils/CollectionGuard.h"
|
||||
#include "Utils/DatabaseGuard.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Utils/transactions.h"
|
||||
#include "VocBase/document-collection.h"
|
||||
#include "VocBase/server.h"
|
||||
|
@ -365,7 +366,7 @@ void CollectorThread::run () {
|
|||
throw;
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
int res = ex.code();
|
||||
LOG_ERROR("got unexpected error in collectorThread::run: %s", TRI_errno_string(res));
|
||||
}
|
||||
|
@ -468,7 +469,7 @@ bool CollectorThread::processQueuedOperations () {
|
|||
try {
|
||||
res = processCollectionOperations((*it2));
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
|
||||
|
@ -704,7 +705,7 @@ int CollectorThread::processCollectionOperations (CollectorCache* cache) {
|
|||
|
||||
res = TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -807,7 +808,7 @@ int CollectorThread::collect (Logfile* logfile) {
|
|||
try {
|
||||
res = transferMarkers(logfile, cid, state.collections[cid], state.operationsCount[cid], sortedOperations);
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -886,7 +887,7 @@ int CollectorThread::transferMarkers (Logfile* logfile,
|
|||
queueOperations(logfile, cache);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "Basics/ReadLocker.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Basics/WriteLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "VocBase/server.h"
|
||||
#include "Wal/AllocatorThread.h"
|
||||
#include "Wal/CollectorThread.h"
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
#include "Basics/FileUtils.h"
|
||||
#include "Basics/conversions.h"
|
||||
#include "Basics/files.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/collection.h"
|
||||
#include "VocBase/replication-applier.h"
|
||||
#include "VocBase/voc-shaper.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
#include "Wal/Slots.h"
|
||||
#include "Utils/Exception.h"
|
||||
|
||||
using namespace triagens::wal;
|
||||
|
||||
|
@ -452,7 +452,7 @@ int RecoverState::executeRemoteOperation (TRI_voc_tick_t databaseId,
|
|||
THROW_ARANGO_EXCEPTION(res);
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -536,7 +536,7 @@ int RecoverState::executeSingleOperation (TRI_voc_tick_t databaseId,
|
|||
// commit the operation
|
||||
res = trx->commit();
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
@ -1620,7 +1620,7 @@ int RecoverState::abortOpenTransactions () {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
res = ex.code();
|
||||
}
|
||||
catch (...) {
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RemoverThread.h"
|
||||
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
|
||||
using namespace triagens::wal;
|
||||
|
@ -108,7 +109,7 @@ void RemoverThread::run () {
|
|||
worked = _logfileManager->removeLogfiles();
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
int res = ex.code();
|
||||
LOG_ERROR("got unexpected error in removerThread::run: %s", TRI_errno_string(res));
|
||||
}
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SynchroniserThread.h"
|
||||
|
||||
#include "Basics/logging.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Utils/Exception.h"
|
||||
#include "Basics/Exceptions.h"
|
||||
#include "VocBase/server.h"
|
||||
#include "Wal/LogfileManager.h"
|
||||
#include "Wal/Slots.h"
|
||||
|
@ -137,7 +138,7 @@ void SynchroniserThread::run () {
|
|||
}
|
||||
}
|
||||
}
|
||||
catch (triagens::arango::Exception const& ex) {
|
||||
catch (triagens::basics::Exception const& ex) {
|
||||
int res = ex.code();
|
||||
LOG_ERROR("got unexpected error in synchroniserThread: %s", TRI_errno_string(res));
|
||||
}
|
||||
|
|
|
@ -53,15 +53,29 @@ RestBaseHandler::RestBaseHandler (HttpRequest* request)
|
|||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- HttpHandler methods
|
||||
// --SECTION-- Handler methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void RestBaseHandler::handleError (TriagensError const& error) {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestBaseHandler::handleError (const TriagensError& error) {
|
||||
generateError(HttpResponse::SERVER_ERROR,
|
||||
TRI_ERROR_INTERNAL,
|
||||
DIAGNOSTIC_INFORMATION(error));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RestBaseHandler::handleError (const Exception& error) {
|
||||
generateError(HttpResponse::responseCode(error.code()),
|
||||
error.code(),
|
||||
DIAGNOSTIC_INFORMATION(error));
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace triagens {
|
|||
RestBaseHandler (rest::HttpRequest* request);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- HttpHandler methods
|
||||
// --SECTION-- Handler methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
public:
|
||||
|
@ -74,6 +74,12 @@ namespace triagens {
|
|||
|
||||
void handleError (basics::TriagensError const&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleError (basics::Exception const&);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public methods
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -32,10 +32,24 @@
|
|||
using namespace std;
|
||||
using namespace triagens::basics;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- private variables
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief controls if backtraces are printed with exceptions
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static bool WithBackTrace = false;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class TriagensError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief base class for all errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -57,20 +71,27 @@ TriagensError::TriagensError (string const& type, string const& details, char co
|
|||
TRI_GetBacktrace(_message);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TriagensError::~TriagensError () throw () {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the error messages
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char const * TriagensError::what () const throw() {
|
||||
return _message.c_str();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class InternalError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for internal errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -79,12 +100,25 @@ InternalError::InternalError (string const& details, char const* file, int line)
|
|||
: TriagensError("internal error", details, file, line) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for internal errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
InternalError::InternalError (std::exception const& ex, char const* file, int line)
|
||||
: TriagensError("internal exception", ex.what(), file, line) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
InternalError::~InternalError () throw () {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class OutOfMemoryError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for out-of-memory errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -93,6 +127,17 @@ OutOfMemoryError::OutOfMemoryError (char const* file, int line)
|
|||
: TriagensError("out-of-memory", "", file, line) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
OutOfMemoryError::~OutOfMemoryError () throw () {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class FileError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for file errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -122,12 +167,16 @@ FileError::FileError (string const& func,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FileError::~FileError () throw () {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sets the filename
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void FileError::setFilename (string const& filename) {
|
||||
_filename = filename;
|
||||
|
@ -137,6 +186,10 @@ void FileError::setFilename (string const& filename) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class ParseError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for parse errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -152,7 +205,16 @@ ParseError::ParseError (string const& details,
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ParseError::~ParseError () throw () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief sets the line number
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ParseError::setLineNumber (int lineNumber) {
|
||||
_lineNumber = lineNumber;
|
||||
|
@ -162,6 +224,10 @@ void ParseError::setLineNumber (int lineNumber) {
|
|||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class ParameterError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for parameter errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -181,11 +247,160 @@ ParameterError::ParameterError (string const& parameter,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ParameterError::~ParameterError () throw () {
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class Exception
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief controls whether a backtrace is created for each exception
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Exception::SetVerbose (bool verbose) {
|
||||
WithBackTrace = verbose;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor, without format string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::Exception (int code,
|
||||
char const* file,
|
||||
int line)
|
||||
: _errorMessage(TRI_errno_string(code)),
|
||||
_file(file),
|
||||
_line(line),
|
||||
_code(code) {
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
#if HAVE_BACKTRACE
|
||||
if (WithBackTrace) {
|
||||
_errorMessage += std::string("\n\n");
|
||||
TRI_GetBacktrace(_errorMessage);
|
||||
_errorMessage += std::string("\n\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the error message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
string Exception::message () const throw () {
|
||||
return _errorMessage;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns the error code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int Exception::code () const throw () {
|
||||
return _code;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief adds to the message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Exception::addToMessage (string More) {
|
||||
_errorMessage += More;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief constructor, for creating an exception with an already created
|
||||
/// error message (normally based on error templates containing %s, %d etc.)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::Exception (int code,
|
||||
string const& errorMessage,
|
||||
char const* file,
|
||||
int line)
|
||||
: _errorMessage(errorMessage),
|
||||
_file(file),
|
||||
_line(line),
|
||||
_code(code) {
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
#if HAVE_BACKTRACE
|
||||
if (WithBackTrace) {
|
||||
_errorMessage += std::string("\n\n");
|
||||
TRI_GetBacktrace(_errorMessage);
|
||||
_errorMessage += std::string("\n\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief destructor
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Exception::~Exception () throw () {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return exception message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const char* Exception::what () const throw () {
|
||||
return _errorMessage.c_str();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief construct an error message from a template string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string Exception::FillExceptionString (int code, ...) {
|
||||
char const* format = TRI_errno_string(code);
|
||||
TRI_ASSERT(format != nullptr);
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// Obviously the formatstring of the error code has to support parameters.
|
||||
TRI_ASSERT(strchr(format, '%') != nullptr);
|
||||
#endif
|
||||
|
||||
char buffer[1024];
|
||||
va_list ap;
|
||||
va_start(ap, code);
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1] = '\0'; // Windows
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief construct an error message from a template string
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string Exception::FillFormatExceptionString (char const* format, ...) {
|
||||
TRI_ASSERT(format != nullptr);
|
||||
|
||||
#ifdef TRI_ENABLE_MAINTAINER_MODE
|
||||
// Format #1 should come from the macro...
|
||||
TRI_ASSERT(strchr(format, '%') != nullptr);
|
||||
// Obviously the user has to give us a format string.
|
||||
TRI_ASSERT(strchr(strchr(format, '%'), '%') != nullptr);
|
||||
#endif
|
||||
|
||||
char buffer[1024];
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer) - 1, format, ap);
|
||||
va_end(ap);
|
||||
buffer[sizeof(buffer) - 1] = '\0'; // Windows
|
||||
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
///
|
||||
/// DISCLAIMER
|
||||
///
|
||||
/// Copyright 2014 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2014-2015 ArangoDB GmbH, Cologne, Germany
|
||||
/// Copyright 2004-2014 triAGENS GmbH, Cologne, Germany
|
||||
///
|
||||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -23,7 +23,8 @@
|
|||
/// Copyright holder is ArangoDB GmbH, Cologne, Germany
|
||||
///
|
||||
/// @author Dr. Frank Celler
|
||||
/// @author Copyright 2014, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Jan Steemann
|
||||
/// @author Copyright 2014-2015, ArangoDB GmbH, Cologne, Germany
|
||||
/// @author Copyright 2009-2013, triAGENS GmbH, Cologne, Germany
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -130,6 +131,48 @@
|
|||
#define THROW_PARAMETER_ERROR(parameter, details, func) \
|
||||
throw triagens::basics::ParameterError(parameter, details, func, __FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION(code) \
|
||||
throw triagens::basics::Exception(code, __FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and arbitrary
|
||||
/// arguments (to be inserted in printf-style manner)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_PARAMS(code, ...) \
|
||||
throw triagens::basics::Exception( \
|
||||
code, \
|
||||
triagens::basics::Exception::FillExceptionString( \
|
||||
code, \
|
||||
__VA_ARGS__), \
|
||||
__FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and arbitrary
|
||||
/// arguments (to be inserted in printf-style manner)
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_FORMAT(code, format, ...) \
|
||||
throw triagens::basics::Exception( \
|
||||
code, \
|
||||
triagens::basics::Exception::FillFormatExceptionString( \
|
||||
"%s: " format, \
|
||||
TRI_errno_string(code), \
|
||||
__VA_ARGS__), \
|
||||
__FILE__, __LINE__)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief throws an arango exception with an error code and an already-built
|
||||
/// error message
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define THROW_ARANGO_EXCEPTION_MESSAGE(code, message) \
|
||||
throw triagens::basics::Exception(code, message, __FILE__, __LINE__)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- public types
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -137,6 +180,10 @@
|
|||
namespace triagens {
|
||||
namespace basics {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class TriagensError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief base class for all errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -161,6 +208,10 @@ namespace triagens {
|
|||
int _line;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class InternalError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for internal errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -169,8 +220,14 @@ namespace triagens {
|
|||
public:
|
||||
InternalError (std::string const& details, char const* file, int line);
|
||||
InternalError (std::exception const& ex, char const* file, int line);
|
||||
|
||||
~InternalError () throw ();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class OutOfMemoryError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for out-of-memory errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -178,8 +235,14 @@ namespace triagens {
|
|||
class OutOfMemoryError : public TriagensError {
|
||||
public:
|
||||
OutOfMemoryError (char const* file, int line);
|
||||
|
||||
~OutOfMemoryError () throw ();
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class FileError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for file errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -206,6 +269,10 @@ namespace triagens {
|
|||
int _error;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class ParseError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for parse errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -217,6 +284,8 @@ namespace triagens {
|
|||
char const* file,
|
||||
int line);
|
||||
|
||||
~ParseError () throw ();
|
||||
|
||||
public:
|
||||
void setLineNumber (int);
|
||||
|
||||
|
@ -224,6 +293,10 @@ namespace triagens {
|
|||
int _lineNumber;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class ParameterError
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief exception for parameter errors
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -242,6 +315,45 @@ namespace triagens {
|
|||
std::string _parameter;
|
||||
std::string _func;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- class Exception
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief arango exception type
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class Exception : public virtual std::exception {
|
||||
public:
|
||||
static std::string FillExceptionString (int, ...);
|
||||
static std::string FillFormatExceptionString (char const * format, ...);
|
||||
static void SetVerbose (bool);
|
||||
|
||||
public:
|
||||
Exception (int code,
|
||||
char const* file,
|
||||
int line);
|
||||
|
||||
Exception (int code,
|
||||
std::string const& errorMessage,
|
||||
char const* file,
|
||||
int line);
|
||||
|
||||
~Exception () throw ();
|
||||
|
||||
public:
|
||||
char const * what () const throw ();
|
||||
std::string message () const throw ();
|
||||
int code () const throw ();
|
||||
void addToMessage (std::string More);
|
||||
|
||||
protected:
|
||||
std::string _errorMessage;
|
||||
char const* _file;
|
||||
int const _line;
|
||||
int const _code;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -297,7 +297,7 @@ bool JsonHelper::checkAndGetBooleanValue (TRI_json_t const* json,
|
|||
if (! isBoolean(sub)) {
|
||||
std::string msg = "The attribute '" + std::string(name)
|
||||
+ "' was not found or is not a boolean.";
|
||||
THROW_INTERNAL_ERROR(msg);
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, msg);
|
||||
}
|
||||
|
||||
return sub->_value._boolean;
|
||||
|
@ -315,7 +315,7 @@ std::string JsonHelper::checkAndGetStringValue (TRI_json_t const* json,
|
|||
if (! isString(sub)) {
|
||||
std::string msg = "The attribute '" + std::string(name)
|
||||
+ "' was not found or is not a string.";
|
||||
THROW_INTERNAL_ERROR(msg);
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, msg);
|
||||
}
|
||||
return string(sub->_value._string.data, sub->_value._string.length - 1);
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ TRI_json_t const* JsonHelper::checkAndGetObjectValue (TRI_json_t const* json,
|
|||
if (! isObject(sub)) {
|
||||
std::string msg = "The attribute '" + std::string(name)
|
||||
+ "' was not found or is not an object.";
|
||||
THROW_INTERNAL_ERROR(msg);
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, msg);
|
||||
}
|
||||
|
||||
return sub;
|
||||
|
@ -350,7 +350,7 @@ TRI_json_t const* JsonHelper::checkAndGetArrayValue (TRI_json_t const* json,
|
|||
if (! isArray(sub)) {
|
||||
std::string msg = "The attribute '" + std::string(name)
|
||||
+ "' was not found or is not an array.";
|
||||
THROW_INTERNAL_ERROR(msg);
|
||||
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_BAD_PARAMETER, msg);
|
||||
}
|
||||
|
||||
return sub;
|
||||
|
|
|
@ -72,7 +72,11 @@ namespace {
|
|||
return status_t(HANDLER_DONE);
|
||||
};
|
||||
|
||||
void handleError (TriagensError const& error) {
|
||||
void handleError (const TriagensError& error) {
|
||||
_response = createResponse(HttpResponse::SERVICE_UNAVAILABLE);
|
||||
};
|
||||
|
||||
void handleError (const Exception& error) {
|
||||
_response = createResponse(HttpResponse::SERVICE_UNAVAILABLE);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -204,7 +204,11 @@ namespace triagens {
|
|||
|
||||
|
||||
|
||||
void PathHandler::handleError (TriagensError const&) {
|
||||
void PathHandler::handleError (const TriagensError&) {
|
||||
_response = createResponse(HttpResponse::SERVER_ERROR);
|
||||
}
|
||||
|
||||
void PathHandler::handleError (const Exception&) {
|
||||
_response = createResponse(HttpResponse::SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,13 @@ namespace triagens {
|
|||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleError (basics::TriagensError const&);
|
||||
void handleError (const basics::TriagensError&);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// {@inheritDoc}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void handleError (const basics::Exception&);
|
||||
|
||||
private:
|
||||
std::string path;
|
||||
|
|
|
@ -187,7 +187,13 @@ namespace triagens {
|
|||
/// @brief handles error
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void handleError (basics::TriagensError const&) = 0;
|
||||
virtual void handleError (const basics::TriagensError&) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief handles error
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void handleError (const basics::Exception&) = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief creates a job
|
||||
|
|
|
@ -190,6 +190,53 @@ HttpResponse::HttpResponseCode HttpResponse::responseCode (const string& str) {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get http response code from integer error code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
HttpResponse::HttpResponseCode HttpResponse::responseCode (int code) {
|
||||
TRI_ASSERT(code != TRI_ERROR_NO_ERROR);
|
||||
|
||||
switch (code) {
|
||||
case TRI_ERROR_ARANGO_DOCUMENT_KEY_BAD:
|
||||
case TRI_ERROR_ARANGO_DOCUMENT_KEY_UNEXPECTED:
|
||||
case TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID:
|
||||
case TRI_ERROR_BAD_PARAMETER:
|
||||
case TRI_ERROR_CLUSTER_MUST_NOT_CHANGE_SHARDING_ATTRIBUTES:
|
||||
case TRI_ERROR_CLUSTER_MUST_NOT_SPECIFY_KEY:
|
||||
return BAD;
|
||||
|
||||
case TRI_ERROR_ARANGO_READ_ONLY:
|
||||
return FORBIDDEN;
|
||||
|
||||
case TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND:
|
||||
case TRI_ERROR_ARANGO_DOCUMENT_NOT_FOUND:
|
||||
return NOT_FOUND;
|
||||
|
||||
case TRI_ERROR_REQUEST_CANCELED:
|
||||
case TRI_ERROR_QUERY_KILLED:
|
||||
return REQUEST_TIMEOUT;
|
||||
|
||||
case TRI_ERROR_ARANGO_CONFLICT:
|
||||
case TRI_ERROR_ARANGO_GEO_INDEX_VIOLATED:
|
||||
case TRI_ERROR_ARANGO_UNIQUE_CONSTRAINT_VIOLATED:
|
||||
return CONFLICT;
|
||||
|
||||
case TRI_ERROR_ARANGO_OUT_OF_KEYS:
|
||||
case TRI_ERROR_CLUSTER_SHARD_GONE:
|
||||
case TRI_ERROR_CLUSTER_TIMEOUT:
|
||||
return SERVER_ERROR;
|
||||
|
||||
case TRI_ERROR_CLUSTER_UNSUPPORTED:
|
||||
return NOT_IMPLEMENTED;
|
||||
|
||||
case TRI_ERROR_OUT_OF_MEMORY:
|
||||
case TRI_ERROR_INTERNAL:
|
||||
default:
|
||||
return SERVER_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the batch error count header
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -150,6 +150,12 @@ namespace triagens {
|
|||
|
||||
static HttpResponseCode responseCode (std::string const& str);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get http response code from integer error code
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static HttpResponseCode responseCode (int);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return the batch response error count header
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue