Updated error handling for plain text api returns