I think this is one of the Selenium question which has not been discussed more.
I have never used such mechanism but did you try to execute it on a page which has js errors?
jyo wrote
((JavascriptExecutor) driver).executeScript("return window.jsErrors");
If it works then it might be a way to go about.
I guess you could use a java-listeners to keep check on your pages. Thought I am not sure how this could be achieved.
There is one Interesting article on catching js errors using Selenium -
http://www.silverwareconsulting.com/index.cfm/2010/6/7/Checking-for-JavaScript-Errors-with-SeleniumIn a gist, you need to inject js on every page of site as described in the article. This should be done by development team.
Now to see if it works, have one js error injected to a page explicitly and follow the instruction in article to see if Selenium catches it.
~ seleniumtests.com