facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.96k forks source link

fopen - incorrect Exception thrown #1108

Open scottybo opened 5 years ago

scottybo commented 5 years ago

There seems to be a small flaw in exception handling for file downloads.

For example, if I run

new FacebookFile('https://path.to/file-that-doesnt-exist.png');

The Exception that gets thrown is a standard Exception rather than a FacebookSDKException. The output will be similar to:

fopen(https://path.to/file-that-doesnt-exist.png): failed to open stream: Connection timed out  

This means that I can't do proper error handling unless I run my own check to see if the file exists first, which is an option but if you can do proper handling, then that would be good too!