Parse error messages to extract error level

Also collapse whitespace in error messages to improve readability.