The stopOnError
and continueOnError
flags indicate what to do (stop or continue) with the remainder of the current request if an error occurs within the current request.
For example, if you did this:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerAddRq requestID="1">
...
</CustomerAddRq>
<InvoiceAddRq requestID="2">
...
</InvoiceAddRq>
....
You're telling QuickBooks that if an error occurs in the CustomerAddRq
section, ignore it and continue processing the InvoiceAddRq
section (vs. if you used stopOnError
it would not even attempt the InvoiceAddRq
after encountering an error in the CustomerAddRq
section.
However, if you're using the Web Connector correctly (you are) then you're sending multiple separate requests, vs. one batched up request like in the example above. Which means that stopOnError
and continueOnError
are not what you need.
Instead, what you need is to handle the error in your PHP code with an error handler.
Add a function:
/**
* Try to handle an error
*
* @param string $requestID
* @param string $user This is the username of the connected Web Connector user
* @param string $action The action type that experienced an error (i.e. QUICKBOOKS_ADD_CUSTOMER, or QUICKBOOKS_QUERY_CUSTOMER, or etc.)
* @param string $ID The $ID value of the record that experienced an error (usually your primary key for this record)
* @param array $extra
* @param string $err If an error occurs **within the error handler**, put an error message here (i.e. if your error handler experienced an internal error), otherwise, leave this NULL
* @param string $xml
* @param string $errnum The error number or error code which occurred
* @param string $errmsg The error message received from QuickBooks
* @return boolean Return TRUE if the error was handled and you want to continue processing records, or FALSE otherwise
*/
function my_error_handler($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
// ...
// return true; // return TRUE if you want the Web Connector to continue to process requests
// return false; // return FALSE if you want the Web Connector to stop processing requests and report the error
}
And make sure you tell the QuickBooks PHP lib about your new error handler function:
$errmap = array(
// This is an array mapping the error number/code to the error handler function
3070 => 'my_error_handler',
// You can also use static method error handlers if you don't like functions...
// 3070 => 'MyStaticClass::myStaticMethod',
// ... or object instant error handlers.
// 3070 => array( $MyObjectInstance, 'myMethod' ),
// You can also register a "catch-all" error handler to catch all errors:
// '*' => 'my_catchall_error_handler',
);
More info: