I feel like I couldn't find a way to fix this This is one of those life lessons we learn that we can't fix or control everything that happens. Sometimes, life throws crap at us and there is nothing we can do about it. You aren't responsible for your WS's behavior. You are only responsible for YOUR behavior.
Your child is learning that life isn't perfect and sometimes bad things happen. How you deal with this will teach your child a lot. You can teach your child that it is possible to pick ourselves up and move on and have a good life, or you can teach your child that we can refuse to deal with the bad stuff, beat ourselves up over things we have no control, and feel guilty about the stuff that other people do to us. Which one do you want your child learning?
It isn't a failure to have good boundaries and not allow someone to treat us badly. And it is also okay for your child to see you grieving and be sad. You are experiencing a loss and so are they. It is okay to be sad and cry. That is the healthy way to deal with this. But then, at some point, you start to find a new normal and pick the pieces back up and embrace life again.
I felt terrible after my divorce also. I also wanted that perfect happy childhood for my kids. But my kids are surviving wonderfully. They are good kids, honor students, going to and graduating from college, and my eldest is even married now to a very good man. They can survive and thrive.