I had one experience where I panicked while cave diving, back in 2017. Stupid and simple reason.
All of this was probably 20-30 feet from the entrance in clear view of daylight and open water, if I were able to open my eyes underwater. Never had any issues on any other dive.
Downstream side of Cow Spring, fairly close to the entrance, I was having issues with my mask fogging badly (something I've since corrected by using a Magic Eraser to clean the lenses before each dive and then applying anti-fog - not just using anti-fog) and would let it a little bit of water to slosh around on the lenses and clear the fog.
The partial mask flooding turned into me trying to clear the mask unsuccessfully, which introduced more water (now over my nostrils in the mask) - tried clearing it again, unsuccessfully and uneasily as my nostrils were already getting wet every time I inhaled. I have a habit of inhaling through my nose and mouth simultaneously and I don't know why, just always have. By the third time I tried clearing the mask it was about half full of water and I inhaled a good bit of it via my nose, triggering the panic response because I thought I was going to drown inside my mask (like I said, stupid). In my brain at the moment, the only way to stop the phenomenon was to rip my mask off and just pinch my nostrils to get a few good breaths in. Mask off (and retained), but I had not wrapped my arm around the line prior to doing it (and this system is a slow siphon, for those who aren't familiar with it). At that moment, I swam toward the entrance but ended up in a small pocket next to the cave entrance, inside the cavern zone. I wedged myself in between the ceiling and floor rocks because I knew I wouldn't move away from that spot without knowing it, and started signaling my buddy that I was having an issue. Problem was, I was doing a vigorous oval/circle instead of a slash like I thought, which has since turned into an inside joke about being "vigorously okay" LOL. I was trying to control my breathing to slow it down and end the panic attack to facilitate putting on the mask in a controlled manner rather than trying while I was in the midst of the panic and making it even worse.
The part that stuck with me was the two dialogues running concurrently in my brain: one was the panic of being off the line, blind, in an overhead environment that siphons, AND hyperventilating from inhaling a considerable amount water at the beginning of the experience. Just by those metrics, probably the worst situation you could be in without being out of gas or having a medical issue like a heart attack.
The other was telling myself to relax and control my breathing to slow it down. I'm near the entrance, my buddy was behind me and would be finishing his exit shortly (he'd stopped to look at something behind a boulder near the entrance) and see me, I know I have PLENTY of gas (1700-2000psi in each tank), all of my equipment is working, I have my mask in my hand, I have a rough idea of what direction the line is, and I know I'm not going to drift into the cave or cause a silt out because I'm wedged between two rocks.
Ended up exiting sucessfully and taking about a 20 minute surface interval, then doing a clean-up dive to pick up our reel and shake the bad juju off.
Needless to say, I worked on mask removal/replacement for a while after that as I hadn't done it in a year.
To avoid these uncomfortable sensations and emotions they could tough it out, mentally disconnect, use distraction to get away from the feeling—rushing to get it over with. Or, they could slow down, notice the sensations, focus on staying present, and being aware of performing the skill. In the second option, there is exposure to the sensations and emotions, and that exposure is important in allowing habituation. Being more willing to be uncomfortable makes it easier to become familiar with it.
Dr Laura Walton
This is precisely what I'd always done up until the point of my incident with the mask removal & replacement. I was never willing to become comfortable with being uncomfortable in regard to having a flooded mask, and always rushed to get it over with as soon as possible.