A fundamental knowledge of the language's constructs is helpful. An example I recall was when I was helping friends through an intro to comp sci course in college. One of them got a message from the C++ compiler reading "local function definitions are illegal". I knew instantly that the questioner had forgotten to close the braces of a function.
The person who asked me had no clue what "local function definition" even meant, which is perfectly understandable. Jumping to the line containing the error message helps, and reading the message suggested the function definition was in the "wrong place". Knowing how functions work, one might presume this meant they had accidentally tried to declare a function within another function. Of course, knowing about function definitions, that is illegal. How would that happen? Most likely culprit was those braces.
Essentially, I'd recommend taking your time to analyze what the message is really trying to tell you. What does it think you were trying to do, and why did it think that? Reading the documentation per ennuikiller's response doesn't hurt either. Some level of experience is necessary, but logical thinking and deduction will get you far.