With some languages, the syntax highlighting can show an error, if the syntax rules define them. For example, the C syntax definition in my system includes an error for invalid octal numbers:
syn match cOctalError display contained "0\o*\d*"
Or in shell scripts, an unmatched
More commonly, this is achieved via syntax checking plugins which show messages. For example, the syntastic plugin can indicate lines with errors, and the error message given by the program used to check the syntax:
Admittedly, the error is a bit cryptic, and in some cases, can be quite long-winded. But with a bit of practice, this will help you spot errors quickly enough.