The best way to pay for a lawsuit is to get somebody else to pay for it. That is how most insurance companies have things set up when you do work under a master restoration services agreement.
Say you mess up on a job so badly that not only you get sued for the recovery of the property owner’s damages, but the insurance company paying for your work, or the direct-repair network or franchisor that sent you to the job, gets sued as well. In that situation your liability insurance is expected to pay to defend these other parties as well. In other words, the codefendants with you in the lawsuit do not pay; you do, or hopefully, if your insurance is designed properly to address this situation, your insurance company pays on your behalf. In risk management speak, the risk was transferred in a services procurement contract from the codefendant’s onto you and hopefully onto your liability insurance.