How to ignore an exception in php? [closed]

Posted on

Question :

I am consuming a method of a legacy system that generates scanning of some FTP directories and searching for files. However, if it accesses a directory that does not have files, it throws an exception.
Is there any way I can use this method, but ignore it if it generates this exception? (without changing the original method)

    

Answer :

If the goal is to deal with exceptions, nothing better than try / catch :

try {
  chamarMetodo();
}
catch (Exception $e) {
  // lidar com erro
}

For more information, read: link

    

Leave a Reply

Your email address will not be published. Required fields are marked *