That must be a sophisticated charger if it can spot the slight differences between nicad and NiMH, and reject the latter. I wonder if that's really the problem.
Although some shavers have a "quick charge" mechanism to handle "emergencies", I suspect most are little more than trickle chargers.
Suggestion... Try running down the NiMH cells (to 1.1V or so) before putting them in the shaver. NiMHs generally have a higher full-charge voltage, and the charger might be "objecting" to that.
The battery failure might also be Nature's way of reminding you that shaving is unnatural, an affront to one's manhood that should be abandoned post-haste.
"The 2 AA NiCd cells died, I've hot bags of AA NiMh cells..."
That's probably because the cells are making contact when they shouldn't...