"Click" While Macro Is Running

My macro works very often but every once in a while the Mac goes "bink!" while the macro is running. It sounds to me what a key is being hit when the active front app isn't accepting keyboard input.

Is there a way to set the macro to stop on that condition? The other idea is to screen record while I run the app and then be able to pause it and see when the "bink" is happening but... of course, I can't predict when it is going to not work.

It appears that everything is completing correctly but I'd still like to know what is happening.

No, I don't think so. These are the kinds of things that are really hard to debug.

But assuming the macro is controlling an application somehow, could it be that something in the application isn't ready for whatever you're doing sometimes? Like you're not waiting long enough between certain actions, or something like that?

The odd thing is, you would think your macro wouldn't work right when you get the beep.