boto/boto — pull request #917 by allardhoeve (2012-08-16 14:47:07+00:00)
Title: Handle 404 in rds gracefully

Hey there!

When trying to find a certain database, the boto library would throw an exception if you use instance_id filter in rds.get_all_dbinstances. This is because Amazon does not match any dbinstances with the requested instance_id and returns a 404. This is a REST feature.

Currently, boto logs with boto.log.error() and raises an exception. The exception is fine, but the logging prevents anyone from handling the exception cleanly, because we always log.error(), which is most prominent in most installations.

So, when a (perfectly valid) 404 comes along, this patch makes sure to throw an exception but skips the logging. Then the patch handles the Exception in rds.get_all_dbinstances and if the Exception is of type DBInstanceNotFound, returns an empty ResultSet instead of throwing up.

This might break installations that rely on rds.get_all_dbinstances to croak instead of returning an empty list, but the empty list is much, much cleaner.

Please apply.