Form validation – Error Message not displaying


I’ve been using setErrorByName to set the error messages in custom form. My validation passes and it doesn’t allow the form to submit as it contains some error. But the problem is the error message is not displaying. Can anyone help me please?

Drupal version: