parse error messages returned by the API