It sounds like you have a rental agreement and he has breached it. Normally, you can sue on such a contract to have the tenant evicted and for the unpaid rent (equal to all the mortgage payments he was supposed to make). From the perspective of protecting your credit, the debt is in your name and you will bear the credit responsibility of letting the debt go into default and foreclosure. I suggest you contact the mortgage company right away about trying to resolve the delinquency. If you can get the house re-rented you may be able to make the mortgage payments in the future and then try to re-habilitate your credit rating. Or, you may be able to sell the house this Spring for enough to pay off the mortgage. Or, you may want to investigate a 'short sale', which would avoid the foreclosure. Next time you do something like this, do not trust the other person to make your loan payments. Have him/her pay you and you pay your debts yourself. Sorry you are having to go through all this trouble.
I am licensed only in Texas. Offering information of a general nature in response to a question is not intended to be legal advice in your state.
Based on the facts you gave, you may have a right to sue your ex-husband for breach of the agreement. But given that he is out of work and apparently unable to afford to make his own housing payments, collecting money from such a claim might pose a more significant problem. A lawsuit like that would also involve a consumer debt, which can be tricky and can backfire easily if you do not have a competent lawyer handling the claim for you. Depending on the specifics of the agreement, there could be other issues as well such as a counterclaim.
If your house has been listed for foreclosure, but has not been sold yet: you might be able to take the property off the foreclosure list and short sell the property, but only if you obtain the mortgagee's and your ex-husband's consent first. This course could possibly be less harmful to your credit than allowing the house to be sold in foreclosure. Keep in mind, short selling a house would require you to get a real estate agent to list it.
This general opinion DOES NOT create an attorney-client relationship. No communication can ever replace the specific advice of a lawyer. Each person's situation is different, and additional facts can change legal outcomes. You should consult privately with a lawyer if you have a question about a legal dispute.