core-bundle/src/Resources/contao/library/Contao/Message.php
public static function hasError($strScope=TL_MODE)
	{
		$session = System::getContainer()->get('session');

		if (!$session->isStarted())
		{
			return false;
		}

		return $session->getFlashBag()->has(static::getFlashBagKey('error', $strScope));
	}
public static function hasError($strScope=TL_MODE)
	{
		$session = System::getContainer()->get('session');

		if (!$session->isStarted())
		{
			return false;
		}

		return $session->getFlashBag()->has(static::getFlashBagKey('error', $strScope));
	}
Check if there are error messages

@param string $strScope An optional message scope

@return boolean True if there are error messages