something that frustrates me to no end even with people I care about is that not everyone understands that animals and very young children have no developed concept of cause and effect; they do NOT typically do bad things to "spite you" and yelling at them or God forbid hitting them will not help. They do not understand why you are being cruel to them, that they did something "wrong"; only that you are being hostile. (If you are hostile often enough, they will learn, though, that you are not stable or trustworthy, and could turn at any moment, causing either distance and/or for them to act out more.)
What is often more helpful is trying to understand *why* the "bad thing" happened; was it an accident? Were they bored/understimulated? Just testing boundaries? Do they not feel well/could they be in pain or fatigued?
Eliminating or minimizing the source of the behavior is typically more effective than just straight reprimand or taking out frustration almost always.
(I am also not saying animals and young children are indistinguishable, moreso that adults treat both the same in these situations.)
That being said, it's OK to be frustrated or tired yourself handling the situation, it's just too many people take that as an excuse to lash out.
And if you have before? You know you have? It's okay. It's not too late to change your behavior, and especially with animals, if it wasn't severe they typically will still warm up to you with some patience.