Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Handling Errors

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:

= 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.


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.

Zend Framework