php - CakePHP 3 Http Client timeout error handling
I'm trying to use the CakePHP 3 Http Client to check urls for their response status code (404, 301, 200 etc)
$http = new Client(); $response = $http->get($links[$i]['url'],,['timeout' => '10']); $links[$i]['http_status'] = $response->statusCode();
However, if I come across a url that timesout, the entire script fails. I'm having trouble figuring out how to add error handling so that if it does timeout, I can log it and move on.
The solution was to use try/catch. I had tried this initially but missed the \ before Exception on the catch