bduggan / aws-s3-raku

Raku client for AWS S3
6 stars 2 forks source link

Fix `.get($url)` when error #6

Closed jonathanstowe closed 3 years ago

jonathanstowe commented 3 years ago

Currently if there is an error on get($url) it dies with (for example):

Error: 404 Not Found NoSuchKey
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>hello/wxrld.txt</Key><RequestId>Y2BS7JSE0D7ZTNWD</RequestId><HostId>SLhXQenrYg2emKd7LadmdDbLk6sjC/TAaWP7qcziLeavjhWRM8WcndeFcXpyJoKbRzO9PcGJFmI=</HostId></Error>
No such method 'content' for invocant of type 'Any'
  in method get at /home/jonathan/.raku/sources/779A68B2770DBA6C868F3B8802DD2388BC6F6EA9 (WebService::AWS::S3) line 136
  in method get at /home/jonathan/.raku/sources/779A68B2770DBA6C868F3B8802DD2388BC6F6EA9 (WebService::AWS::S3) line 141
  in block <unit> at xx line 13

Because the .get($object) returns Nil thus the attempt to call .content fails.

THis just skips the attempt if $res is undefined.

bduggan commented 3 years ago

Thanks, merged (and updated afterwards to use the call-me-maybe operator)

jonathanstowe commented 3 years ago

I've got another bit around the error handling which I may or may not get to depending on how the 🍻 goes this afternoon 🤣

It's amazing what a somewhat mis-configured "production-to-be" AWS environment throws up 🤣