KeywordUtil.markFailed() shows Test case has Error but i expected it as 'failed'. How to mark Test Fail?

I have used conditional statements in Test case like below:

String msg = "Hello World"
//KeywordLogger log = new KeywordLogger()
if (!(msg.contains('World')))) {
    //    log.logFailed('log - Message does not contain expected text.')
    KeywordUtil.markFailed('Message does not contain expected text.')

KeywordUtil.markFailed() does not fail the testcase.
It shows that Test case has Errors

Even KeywordLogger does not do that.

What should be the approriate way of dealing with suck conditions.
I have to match partial text and mark the test Fail or PAss based on If Condition Result.