The previous examples are naive, i.e. no error handling was shown. It's possible that StrikeIron will return a fault during a method call. Events like bad account credentials or an expired subscription can cause StrikeIron to raise a fault.
An exception will be thrown when such a fault occurs. You should anticipate and catch these exceptions when making method calls to the service:
<?php
$strikeIron = new Zend_Service_StrikeIron(array('username' => 'your-username',
'password' => 'your-password'));
$taxBasic = $strikeIron->getService(array('class' => 'SalesUseTaxBasic'));
try {
$taxBasic->getTaxRateCanada(array('province' => 'ontario'));
} catch (Zend_Service_StrikeIron_Exception $e) {
// error handling for events like connection
// problems or subscription errors
}
The exceptions thrown will always be
Zend_Service_StrikeIron_Exception.
It's important to understand the difference between exceptions and
normal failed method calls. Exceptions occur for
exceptional conditions, such as
the network going down or your subscription expiring.
Failed method calls that are a common occurrence,
such as getTaxRateCanada() not finding the
province you supplied, will not result an in exception.
Note
Every time you make a method call to a StrikeIron service, you should check the response object for validity and also be prepared to catch an exception.




