That's why it is always good to have an emergency fund so you don't get into this hole in the first place.
It will boils down to savings, we should learn how to save for the future as we do not hold the future and we cannot see it, anything can happen even the things that we do not expect, so it's good to be ready all the time and we have to start saving now and instill discipline to succeed.