core-bundle/src/Resources/contao/library/Contao/Message.php
public static function add($strMessage, $strType, $strScope=TL_MODE)
	{
		if ($strMessage == '')
		{
			return;
		}

		if (!\in_array($strType, static::getTypes()))
		{
			throw new \Exception("Invalid message type $strType");
		}

		System::getContainer()->get('session')->getFlashBag()->add(static::getFlashBagKey($strType, $strScope), $strMessage);
	}
public static function add($strMessage, $strType, $strScope=TL_MODE)
	{
		if ($strMessage == '')
		{
			return;
		}

		if (!\in_array($strType, static::getTypes()))
		{
			throw new \Exception("Invalid message type $strType");
		}

		System::getContainer()->get('session')->getFlashBag()->add(static::getFlashBagKey($strType, $strScope), $strMessage);
	}
Add a message

@param string $strMessage The message text
@param string $strType    The message type
@param string $strScope   An optional message scope

@throws \Exception If $strType is not a valid message type