ZF-1942: Zend_Service_Amazon throws Exception if itemSeach() didn't find anything

Description

If itemSeach() is not able to find a match iteamSearch() throws an exception.

Reproduce code

require_once('Zend/Service/Amazon.php');

$key = 'KEY';
$country = 'DE';
$amazon = new Zend_Service_Amazon($key,$country);
$params = array('SearchIndex' => 'Books',
                           'Keywords'=>'sugtsdudfz');
 try {
        $res = $amazon->itemSearch($params);      
 } catch(Zend_Service_Exception $e)
 {
     die ($e->getMessage());
 }

Output:

We did not find any matches for your request. (AWS.ECommerceService.NoExactMatches)

Comments

This behavior is apparently by design. Whenever the Amazon web services return an error response, this error is discovered and used to form the message of a thrown {{Zend_Service_Exception}}. The docblock for {{itemSearch()}} indicates that it may throw {{Zend_Service_Exception}}.

I believe that the proper behavior would be simply to create an empty result set, rather than throwing an exception, because an exception should not be thrown in the course of normal business. For example, it is very often the case that a search would yield no results. This should not result in an exception.

To fix this requires a slight change to backward compatibility, so for now I mark it to be fixed with 1.1.0.

This issue should have been fixed for the 1.5 release.

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Fixed in trunk, no exception will be thrown on an empty resultset anymore.

merged back into 1.7 release branch due to possible 1.7.3 release