improved error message parsing