9 months ago

Catch cURL error with Laravel?

Posted 9 months ago by Azoruk

For my Laravel application, I use the Goutte package to crawl DOMs, which allows me to use guzzle settings.

$goutteClient = new Client();
$guzzleClient = new GuzzleClient(array(
    'timeout' => 15,
$crawler = $goutteClient->request('GET', '');

I'm currently using guzzle's timeout feature, which will return an error like this, for example, when the client times out:

cURL error 28: Operation timed out after 1009 milliseconds with 0 bytes received (see

Now this is cool and all, but I don't actually want it to return a cURL error and stop my program.

I'd prefer something like this:

if (guzzle client timed out) {
    do this
} else {
    do that

How can I do this?

Please sign in or create an account to participate in this conversation.