Read browser console errors in Firefox and IE

How can I get console errors in Firefox and IE?

I can do it in Chrome:
LogEntries logs = driver.manage().logs().get(‘browser’)
for (LogEntry entry : logs) {
println(">>> $entry")
println(">>> $entry.level")

 if(entry.getLevel().toString().equals("SEVERE")) {
throw new Exception(entry.getMessage());
 }

}

but it doesn’t work for Firefox and IE.