code: def extract_bad_ami(e):
          
          msg = e.response['Error']['Message']
          error = e.response['Error']['Code']
          e_ami_ids = None
          if error == 'InvalidAMIID.NotFound':
              e_ami_ids = [
                  e_ami_id.strip() for e_ami_id
                  in msg[msg.find("'[") + 2:msg.rfind("]'")].split(',')]
              log.warning("Image not found %s" % e_ami_ids)
          elif error == 'InvalidAMIID.Malformed':
              e_ami_ids = [msg[msg.find('"') + 1:msg.rfind('"')]]
              log.warning("Image id malformed %s" % e_ami_ids)
          return e_ami_ids
docs: Handle various client side errors when describing images