1
0
Fork 0

Bug fix/less exceptions (#7385) (#7415)

This commit is contained in:
Wilfried Goesgens 2018-11-23 11:15:36 +01:00 committed by Jan
parent c50d346453
commit 4bbd6a02bb
4 changed files with 22 additions and 12 deletions

View File

@ -119,6 +119,12 @@ void AqlFunctionFeature::toVelocyPack(VPackBuilder& builder) {
builder.close();
}
bool AqlFunctionFeature::exists(std::string const& name) const {
auto it = _functionNames.find(name);
return it != _functionNames.end();
}
Function const* AqlFunctionFeature::byName(std::string const& name) {
auto it = _functionNames.find(name);

View File

@ -57,6 +57,8 @@ class AqlFunctionFeature final : public application_features::ApplicationFeature
void toVelocyPack(arangodb::velocypack::Builder&);
Function const* byName(std::string const& name);
bool exists(std::string const& name) const;
private:
// Internal functions
void addTypeCheckFunctions();

View File

@ -90,17 +90,19 @@ void ServerState::findHost(std::string const& fallback) {
// Now look at the contents of the file /etc/machine-id, if it exists:
std::string name = "/etc/machine-id";
try {
_host = arangodb::basics::FileUtils::slurp(name);
while (!_host.empty() &&
(_host.back() == '\r' || _host.back() == '\n' ||
_host.back() == ' ')) {
_host.erase(_host.size() - 1);
}
if (!_host.empty()) {
return;
}
} catch (...) { }
if (arangodb::basics::FileUtils::exists(name)) {
try {
_host = arangodb::basics::FileUtils::slurp(name);
while (!_host.empty() &&
(_host.back() == '\r' || _host.back() == '\n' ||
_host.back() == ' ')) {
_host.erase(_host.size() - 1);
}
if (!_host.empty()) {
return;
}
} catch (...) { }
}
#ifdef __APPLE__
static_assert(sizeof(uuid_t) == 16, "");

View File

@ -35,7 +35,7 @@ bool addFunction(
) {
// check that a function by the given name is not registred to avoid
// triggering an assert inside AqlFunctionFeature::add(...)
if (getFunction(functions, function.name)) {
if (functions.exists(function.name)) {
return false;
}