Throws an exception if an error response comes back from the API