Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal errors – am I doing something wrong? #24

Open
t1mmen opened this issue May 5, 2016 · 5 comments
Open

Fatal errors – am I doing something wrong? #24

t1mmen opened this issue May 5, 2016 · 5 comments

Comments

@t1mmen
Copy link

t1mmen commented May 5, 2016

Using the latest tagged release, I have a check to verify the user's token is valid. I'm currently doing it like this:

$client = new \Evernote\Client($connection['credentials_token'], false);
$advancedClient = $client->getAdvancedClient();
$userStore = $advancedClient->getUserStore();
try {
    $user = $userStore->getUser();
} catch (EDAM\Error\EDAMUserException $e) {
    if ($e->parameter == 'authenticationToken') {
        $this->disableConnection(null, 'Authorization has expired', 401);
    }
}

This works well 99% of cases, but randomly it crashes with the error below. Is there perhaps something I'm doing wrong?

PHP Fatal error:  Uncaught exception 'EDAM\Error\EDAMSystemException' in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php:2611
Stack trace:
#0 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(543): EDAM\UserStore\UserStore_getUser_result->read(Object(Thrift\Protocol\TBinaryProtocol))
#1 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(504): EDAM\UserStore\UserStoreClient->recv_getUser()
#2 [internal function]: EDAM\UserStore\UserStoreClient->getUser('S=s367:U=3c7c31...')
#3 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php(50): call_user_func_array(Array, Array)
#4 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(27): Evernote\Store\Store->__call('getUser', Array)
#5 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(27): Evernote\Store\Store->getUser()
#6 /mnt/task/lib/whatsup/WhatsUp.php(131): EvernoteModel->process(Array, '8g2hasu7498712gyf2yrtF...')
#7 /mnt/task/lib/whatsup/WhatsUp.php(57): WhatsUp->__processQueue(Arra in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php on line 2611

PS: If there's a better way to do this, I'm all ears!

@akhaku
Copy link
Contributor

akhaku commented May 5, 2016

getUser is fine - technically NoteStore.getSyncState is what you should be calling but getUser is okay, too.

Mind catching the EDAMSystemException and printing out the errorCode and message? That will provide more context on what's causing it to fail...

@t1mmen
Copy link
Author

t1mmen commented May 6, 2016

I've added some logging and will let you know what I find. I'll also be doing the same for other exceptions that the following code is generating:

$client = new \Evernote\Client($connection['credentials_token'], false);
$note = $client->getNote($payload['guid']);
$notebook = $client->getNotebook($payload['notebookGuid']);

Here are some traces:

// backtrace 1
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php:717 in EDAM\UserStore\UserStore_getNoteStoreUrl_result::read
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php:678 in EDAM\UserStore\UserStoreClient::recv_getNoteStoreUrl
: in EDAM\UserStore\UserStoreClient::getNoteStoreUrl
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php:25 in ReflectionMethod::invokeArgs
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/AdvancedClient.php:59 in Evernote\Store\Store::__call
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/AdvancedClient.php:59 in Evernote\Store\Store::getNoteStoreUrl
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:376 in Evernote\AdvancedClient::getNoteStore
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:616 in Evernote\Client::getUserNotestore
app/Plugin/Evernote/Controller/EvernoteImportController.php:65 in Evernote\Client::getNote
app/Plugin/Evernote/Controller/EvernoteImportController.php:20 in EvernoteImportController::__getNoteDetails
: in EvernoteImportController::webhook
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Controller/Controller.php:490 in ReflectionMethod::invokeArgs
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:193 in Controller::invokeAction
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:167 in Dispatcher::_invoke
app/webroot/index.php:99 in Dispatcher::dispatch

// backtrace 2
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/NoteStore/NoteStore.php:4355 in EDAM\NoteStore\NoteStore_getSharedNotebookByAuth_result::read
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/NoteStore/NoteStore.php:4316 in EDAM\NoteStore\NoteStoreClient::recv_getSharedNotebookByAuth
: in EDAM\NoteStore\NoteStoreClient::getSharedNotebookByAuth
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php:25 in ReflectionMethod::invokeArgs
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:908 in Evernote\Store\Store::__call
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:908 in Evernote\Store\Store::getSharedNotebookByAuth
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:694 in Evernote\Client::getNoteBookByLinkedNotebook
app/Plugin/Evernote/Controller/EvernoteImportController.php:66 in Evernote\Client::getNotebook
app/Plugin/Evernote/Controller/EvernoteImportController.php:20 in EvernoteImportController::__getNoteDetails
: in EvernoteImportController::webhook
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Controller/Controller.php:490 in ReflectionMethod::invokeArgs
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:193 in Controller::invokeAction
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:167 in Dispatcher::_invoke

// backtrace 3:
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/NoteStore/NoteStore.php:4295 in EDAM\NoteStore\NoteStore_authenticateToSharedNotebook_result::read
Vendor/evernote/evernote-cloud-sdk-php/src/EDAM/NoteStore/NoteStore.php:4255 in EDAM\NoteStore\NoteStoreClient::recv_authenticateToSharedNotebook
: in EDAM\NoteStore\NoteStoreClient::authenticateToSharedNotebook
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php:25 in ReflectionMethod::invokeArgs
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:901 in Evernote\Store\Store::__call
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:901 in Evernote\Store\Store::authenticateToSharedNotebook
Vendor/evernote/evernote-cloud-sdk-php/src/Evernote/Client.php:639 in Evernote\Client::getSharedNotebookAuthResult
app/Plugin/Evernote/Controller/EvernoteImportController.php:65 in Evernote\Client::getNote
app/Plugin/Evernote/Controller/EvernoteImportController.php:20 in EvernoteImportController::__getNoteDetails
: in EvernoteImportController::webhook
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Controller/Controller.php:490 in ReflectionMethod::invokeArgs
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:193 in Controller::invokeAction
Vendor/pear-pear.cakephp.org/CakePHP/Cake/Routing/Dispatcher.php:167 in Dispatcher::_invoke
app/webroot/index.php:99 in Dispatcher::dispatch

@t1mmen
Copy link
Author

t1mmen commented May 10, 2016

I'm having trouble chasing this down.

My current code looks like:

        $client = new \Evernote\Client($connection['credentials_token'], false);
        $advancedClient = $client->getAdvancedClient();

        try {
            $userStore = $advancedClient->getUserStore();
        } catch (EDAM\Error\EDAMSystemException $e) {
            $error = '';
            $error .= 'EDAM\Error\EDAMSystemException errorCode::'.$e->errorCode;
            $error .= 'EDAM\Error\EDAMSystemException message::'.$e->message;
            throw new Exception($error);
        }

Based on the errors I'm getting, I might not be catching them right? Any help would be greatly appreciated.

PHP Fatal error:  Uncaught exception 'EDAM\Error\EDAMSystemException' in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php:2611
Stack trace:
#0 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(543): EDAM\UserStore\UserStore_getUser_result->read(Object(Thrift\Protocol\TBinaryProtocol))
#1 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(504): EDAM\UserStore\UserStoreClient->recv_getUser()
#2 [internal function]: EDAM\UserStore\UserStoreClient->getUser('S=s367:U=3c7c31...')
#3 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php(50): call_user_func_array(Array, Array)
#4 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->__call('getUser', Array)
#5 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->getUser()
#6 /mnt/task/lib/whatsup/WhatsUp.php(131): EvernoteModel->process(Array, '9c151f51b95ef39...')

I'm also seeing these Exceptions:

Fatal error: Uncaught exception 'Thrift\Exception\TTransportException' with message 'THttpClient: Could not connect to www.evernote.com:443//edam/user' in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Thrift/Transport/THttpClient.php:213
Stack trace:
#0 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(521): Thrift\Transport\THttpClient->flush()
#1 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(503): EDAM\UserStore\UserStoreClient->send_getUser('S=s4:U=462a2:E=...')
#2 [internal function]: EDAM\UserStore\UserStoreClient->getUser('S=s4:U=462a2:E=...')
#3 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php(50): call_user_func_array(Array, Array)
#4 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->__call('getUser', Array)
#5 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->getUser()
#6 /mnt/task/lib/whatsup/WhatsUp.php(131): EvernoteModel->process(Array, 'ca8f5ef1a6d409e...')
#7 /mnt/t in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Thrift/Transport/THttpClient.php on line 213
PHP Fatal error:  Uncaught exception 'Thrift\Exception\TTransportException' with message 'THttpClient: Could not connect to www.evernote.com:443//edam/user' in /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Thrift/Transport/THttpClient.php:213
Stack trace:
#0 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(521): Thrift\Transport\THttpClient->flush()
#1 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/EDAM/UserStore/UserStore.php(503): EDAM\UserStore\UserStoreClient->send_getUser('S=s4:U=462a2:E=...')
#2 [internal function]: EDAM\UserStore\UserStoreClient->getUser('S=s4:U=462a2:E=...')
#3 /mnt/task/lib/evernote/evernote-cloud-sdk-php/src/Evernote/Store/Store.php(50): call_user_func_array(Array, Array)
#4 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->__call('getUser', Array)
#5 /mnt/task/lib/whatsup-evernote/EvernoteModel.php(38): Evernote\Store\Store->getUser()
#6 /mnt/task/lib/whatsup/WhatsUp.php(131): EvernoteModel->process(Array, 'ca8f5ef1a6d409e...')

@akhaku
Copy link
Contributor

akhaku commented May 10, 2016

Haven't done php in years so not sure how helpful I can be - do you need to import EDAM\Error\EDAMSystemException? Generally an EDAMSystemException means there's something's wrong in our service (vs an EDAMUserException or EDAMNotFoundException, where something's wrong on the client end) and the errorCode and parameter usually provide more info.

For the TExceptions, that looks like a connectivity issue, your server was having trouble contacting our service. Either the network was down or our service was down (rare, but it happens) - I know we had a few minutes of downtime some time within the last two weeks.

@akhaku
Copy link
Contributor

akhaku commented May 10, 2016

It may be easiest to catch Exception directly and try printing out $e->errorCode and $e->message?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants