Fix crash on missing notification_command.

This commit is contained in:
Michael Friedrich 2013-09-24 18:58:51 +02:00
parent 4082dccf1c
commit 91e0566de0
1 changed files with 6 additions and 4 deletions

View File

@ -337,12 +337,14 @@ void Notification::ExecuteNotificationHelper(NotificationType type, const User::
}
try {
NotificationCommand::Ptr notificationCommand = GetNotificationCommand();
NotificationCommand::Ptr command = GetNotificationCommand();
if (!notificationCommand)
BOOST_THROW_EXCEPTION(std::invalid_argument("Notification command for notification object '" + GetName() + " and user '" + user->GetName() + "' does not exist."));
if (!command) {
Log(LogDebug, "icinga", "No notification_command found for notification '" + GetName() + "'. Skipping execution.");
return;
}
GetNotificationCommand()->Execute(GetSelf(), user, cr, type);
command->Execute(GetSelf(), user, cr, type);
{
ObjectLock olock(this);