I'm fetching some data from DB and trying to run Google Natural language API on it. Everything works fine unless it finds some language which GNL API does not recognize. And it throws this exception.
Fatal error: Uncaught Google\Cloud\Core\Exception\BadRequestException: { "error": { "code": 400, "message": "The language ar is not supported for syntax analysis.", "status": "INVALID_ARGUMENT" } }
I just want to skip this exception and wants to continue the loop. How can i do this? Any help will be appreciated.
You should just catch this kind of exception and continue execution.
foreach($languages as $language) {
try {
$response = $apiClient->call($language);
// process response
}
catch (Google\Cloud\Core\Exception\BadRequestException $exception) {
// skip or (better) log this exception
}
}