Was this a one-off deal OR part of a series of issues?
If it's a one-off deal, I would talk to your DM about how things are going in the game & why it's making you unhappy. A good DM should be able to take such input & weave things into something a bit more enjoyable. Just be aware that sometimes, sad & upsetting things may happen in the stories that we weave in order to make them more memorable or rewarding. We can't have everything be all "sunshine & lollipops" all the time.
You should be able to separate yourself from your character. While you have poured your blood, sweat & tears into the character... it is only a fictional character & shouldn't be an integral part of your life as you'll eventually have to let that character go.
HOWEVER, if such actions don't seem justified or was in retaliation of IRL events... then you may need to confront your DM with fellow players. If such actions in-game keeps occurring, your DM may not be keeping in-tune with your group or players desires... which may be decent reason to break off from that group or person. Role-playing games (like D&D) are a group activity that should be enjoyed by all involved. If anybody is deeply unhappy in the long-run (short-term unhappiness is bound to happen periodically), then something isn't working & needs to be addressed so it can be remedied.
While I cannot provide the perfect solution here, since I only have a limited amount of biased information by you (hence why I'm taking things with a grain of salt because I don't have the whole story)... I hope this provides some insight to the potential options you have.