It's normally caused by a failure within a web application.
If it's open code (you can actually see it) then you might have an line number and more accurate message logs in the log files for the site. If it's compiled code, well, you're a bit more stuck, in that case it depends which application it is.
Chris