Dealing with a half-expected error

I’ve got some code that adds a rule to an AWS security group using the ec2_group module. The problem is that if the rule I am adding already exists, Ansible throws an error.

I am a bit puzzled as to why; normally Ansible would just say “good, it’s there already, job done”, but in this case it objects. It’s always going to fail on all but the first run.

How can I field an error, inspect it, and then continue with the playbook if I so choose?

Regards, K.