I have this function which is able to get status code of URLS, if a fake URL is provided, it simply through exceptions that says "fake url". i want to handle that exception and treat it like 404, the site is down.
private function getStatusCode($url)
{
$response = $this->client->get($url, [
'http_errors' => false
]);
return $response->getStatusCode();
}
i tried this code but doesnt help. i need your help to figure it out?
private function getStatusCode($url)
{
try{
$response = $this->client->get($url, [
'http_errors' => false
]);
return $response->getStatusCode();
}
//catch specific exception....
catch(QueryException $e)
{
//...and do whatever you want
return $response;
}
}