aws-sdk-perl icon indicating copy to clipboard operation
aws-sdk-perl copied to clipboard

Paws::EC2::DescribeVolumes fails with perl error when non existent VolumeIds is specified

Open jmonfar opened this issue 6 years ago • 1 comments

When something like:

$ec2->DescribeVolumes(VolumeIds => [ $snapshot->'VolumeId' ])

is executed with a non existent 'VolumeId' the code stops with perl error and aborting execution.

One would expect a 'undefined' result, not a perl error and stopping the execution.

jmonfar avatar Jun 03 '19 14:06 jmonfar

Hi,

This behaviour is by design :( The AWS API communicates the failure to find a volume with an HTTP error, that gets transformed to an exeption by Paws.

You can do something like

my $res = eval { $ec2->DescribeVolumes(...) };

To get the behaviour your looking for. Note that with this code ANY (even unrelated to the volume not existing) exception will be caught. If you want to treat the exception, remember that Paws throws exception objects with a code attribute that you can normally compare to see if it's the exception you were expecting.

pplu avatar Jun 04 '19 07:06 pplu