title: Exception handling in Symfony 2 Crawler
body: <p>I have this code</p>
  
  <pre><code>   try{
  
      $totalpages=$crawler-&gt;filter('.button-see-more');
  
          $totalpages=$totalpages-&gt;extract(array('data-total-pages'))[0];
  
          if($totalpages&gt;0)
              for($i=1;$i&lt;=$totalpages;$i++)
              {
                  $client-&gt;request('GET', 'http://www.daraz.pk/catalog/getproducts/?pathInfo=phones%2Fqmobile&amp;page='.$i.'&amp;YII_CSRF_TOKEN='.$CSRF, array(), array(), array(
                      'HTTP_X-Requested-With' =&gt; 'XMLHttpRequest',
                  ));
                  echo $i.'th page: '.$client-&gt;getResponse()-&gt;getContent()."\r\n";
              }
  
  
  }
  catch (InvalidArgumentException $e) {
      echo 'Caught exception: ',  $e-&gt;getMessage(), "\n";
  }
  </code></pre>
  
  <p>According to the doc pages</p>
  
  <pre><code> $totalpages=$crawler-&gt;filter('.button-see-more');
  </code></pre>
  
  <p>when the filter doesn't match anytyhing it should throw an InvalidArgumentException which is not thrown, rather in the console I get </p>
  
  <blockquote>
    <p>PHP Notice:  Undefined offset: 0 in</p>
  </blockquote>
  
  <p>How can I catch this?</p>