That depends quite a bit on how much your soon to be ex is willing to cooperate.
If you are NOT behind on your payments and you have decent credit, this is a good time to refinance. However, you will need to be able to qualify for the loan on your own, but the rates are very low right now and one of my favorite loan officers tells me there is a fantastic deal from FHA right now that is very low cost.
If you are in a hardship situation and you cannot refinance, you may want to do a short sale. But you will need the complete cooperation of EVERYONE on the mortgage. Even if your ex quit claims the deed over to you as part of the divorce, the lender will demand their information and cooperation in a short sale.
A full foreclosure is the least attractive option, but it is an option. However, keep in mind that this can follow you for the rest of your life because every mortgage application will ask you "have you EVER had a foreclosure". And even with FHA, it will take a MINIMUM of 3 years (possibly longer) to qualify for another mortage.
Having said that, you may want to get the divorce completed before you take any action.