Fix possible crash in Add{Comment,Downtime}

refs #11112
This commit is contained in:
Michael Friedrich 2016-05-11 16:12:09 +02:00 committed by Gunnar Beutner
parent ff24863a72
commit a6e70a155d
4 changed files with 9 additions and 4 deletions

View File

@ -144,7 +144,7 @@ void ExternalCommandListener::CommandPipeThread(const String& commandPath)
ExternalCommandProcessor::Execute(command);
} catch (const std::exception& ex) {
Log(LogWarning, "ExternalCommandListener")
<< "External command failed." << DiagnosticInformation(ex);
<< "External command failed: " << DiagnosticInformation(ex);
}
}
}

View File

@ -195,6 +195,9 @@ String Comment::AddComment(const Checkable::Ptr& checkable, CommentType entryTyp
Comment::Ptr comment = Comment::GetByName(fullName);
if (!comment)
BOOST_THROW_EXCEPTION(std::runtime_error("Could not create comment."));
Log(LogNotice, "Comment")
<< "Added comment '" << comment->GetName() << "'.";

View File

@ -251,12 +251,14 @@ String Downtime::AddDowntime(const Checkable::Ptr& checkable, const String& auth
Downtime::Ptr downtime = Downtime::GetByName(fullName);
if (!downtime)
BOOST_THROW_EXCEPTION(std::runtime_error("Could not create downtime."));
Log(LogNotice, "Downtime")
<< "Added downtime '" << downtime->GetName()
<< "' between '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", startTime)
<< "' and '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", endTime) << "'.";
return fullName;
}

View File

@ -1210,7 +1210,7 @@ void ExternalCommandProcessor::AddHostComment(double, const std::vector<String>&
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add host comment for non-existent host '" + arguments[0] + "'"));
if (arguments[2].IsEmpty() || arguments[3].IsEmpty())
BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment may not be empty"));
BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment must not be empty"));
Log(LogNotice, "ExternalCommandProcessor")
<< "Creating comment for host " << host->GetName();
@ -1234,7 +1234,7 @@ void ExternalCommandProcessor::AddSvcComment(double, const std::vector<String>&
BOOST_THROW_EXCEPTION(std::invalid_argument("Cannot add service comment for non-existent service '" + arguments[1] + "' on host '" + arguments[0] + "'"));
if (arguments[3].IsEmpty() || arguments[4].IsEmpty())
BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment may not be empty"));
BOOST_THROW_EXCEPTION(std::invalid_argument("Author and comment must not be empty"));
Log(LogNotice, "ExternalCommandProcessor")
<< "Creating comment for service " << service->GetName();