I don't know that ALL pets can, I wouldn't put much stake in your goldfish knowing how you feel... I'm not even sure cats do, in my experience. But dogs on the other hand have evolved with humans for thousands of years and I think they have adapted to us a lot. There is research that dogs wag their tails only because humans think it's cute, and they also have the ability to see where our eyes are looking and follow our line of sight. I find these things to be very impressive and it wouldn't surprise me if they've learned to read much more about our behavior than we know so far. Also, animals seem to sometimes be able to sense things that we humans can't, and we can't explain even how they do it. I wouldn't at all be surprised if dogs have picked up a sense to detect if their owner is feeling an extreme emotion. It's fun to think about, dogs really are amazing animals!