Hindsight and thinking things through makes it seem like it was such an easy solution and you totally failed but in the moment you are in shock - have nfi what to do and just react. And that is ok.
My DS is 3.5 and is still doing ridiculous things. He *knows* some of these things are naughty but still does it.
It still frustrates me. I lose my cool. But that does not make anyone a bad parent.
And if its the first time its happened - it shocks you. Just like the first time DS swore. I had no idea what to do. DH was in shock. DS seemed oblivious to what happened.
It'll be ok