Issues

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

Issue Type: Bug Created: 2007-09-13T10:05:44.000+0000 Last Updated: 2009-01-14T13:34:14.000+0000 Status: Resolved Fix version(s): - 1.7.3 (19/Jan/09)

Reporter: Carsten Möhrke (donnerchen) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Service_Amazon

Related issues: Attachments:

Description

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

Reproduce code

<pre class="literal">
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:

<pre class="literal">
We did not find any matches for your request. (AWS.ECommerceService.NoExactMatches)

Comments

Posted by Darby Felton (darby) on 2007-09-20T10:45:12.000+0000

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.

Posted by Wil Sinclair (wil) on 2008-03-21T17:05:31.000+0000

This issue should have been fixed for the 1.5 release.

Posted by Wil Sinclair (wil) on 2008-04-18T13:11:53.000+0000

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

Posted by Benjamin Eberlei (beberlei) on 2009-01-08T06:30:51.000+0000

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

Posted by Benjamin Eberlei (beberlei) on 2009-01-14T13:17:01.000+0000

merged back into 1.7 release branch due to possible 1.7.3 release

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts