Having a pet hurt your child

Today was a first for me. I have cats and a daughter that's almost 2 and a half. She's been scratched by them before, but always because she hit them or something so it made sense they defended themselves and swatted her away. She's been getting much better about how to gently handle the cats.

today she was petting one very gently. this cat is also the main one that likes her, goes to her for pets, deals with all the drool, etc. it's very sweet. Out of nowhere he grabbed her head with his claws and bit her on the head. He left scratch marks on her face. I was sitting right next to her so I know she didn't so anything to hurt him. I told him that was bad and put him in the basement for a short while so I could console her because she was really scared more than hurt by it.

I guess I just want to hear about other experiences like this and how to forgive your pet and trust them again.