dropbox-php-sdk icon indicating copy to clipboard operation
dropbox-php-sdk copied to clipboard

Catching dropbox api error

Open vauntmag opened this issue 7 years ago • 3 comments

Is there a way to catch the errors thrown by the dropbox api? Currently if a folder or file is not found, the api returns an error message, but Guzzle returns a fatal error...is there a way to capture that instead of throwing a fatal error?

Thank you so much for your help!

vauntmag avatar Apr 18 '18 12:04 vauntmag

I came across the same issue. I fixed it by catching the exception this way:

<?php
        try {
            $folder = $dropbox->getMetadata("/Category");
        } catch (\Exception $e) {

        }
?>

codefueluk avatar Apr 20 '18 06:04 codefueluk

Thank you so much for your reply.

Now, a really dumb question:

I use the following to connect:

$app = new DropboxApp( "all params required" ); $dropbox = new Dropbox($app);

I noticed you use the method connectToDropbox(), which I can’t seem to find in the documentation…can you please tell me what is the difference and if I should connect that way instead?

Many thanks in advance for all your help!

On 20 Apr 2018, at 08:19, Codefuel [email protected] wrote:

I came across the same issue. I fixed it by catching the exception this way:

connectToDropbox(); try { $folder = $dropbox->getMetadata("/Category"); } catch (\Exception $e) { } ?>

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kunalvarma05/dropbox-php-sdk/issues/125#issuecomment-382991419, or mute the thread https://github.com/notifications/unsubscribe-auth/AksDIzmg9ZjiHq9iYrgWfdStxLrRW8U6ks5tqX4HgaJpZM4TZ9qW.

vauntmag avatar Apr 20 '18 10:04 vauntmag

That is a function I have created to wrap the connection in. It's not needed.

codefueluk avatar Apr 20 '18 11:04 codefueluk