The 다가 clause is what you were partway through and 걸리다 is being caught at it: caught lying, caught eating instant noodles behind the manager's back, caught sleeping, caught doing something else when you should have been paying attention. It reliably implies you were doing something you should not have been. The shorter 다 걸리다 is the same expression with nothing lost.