Ask yourself why you are doing this, is it for fun? Quit right away and do something else. Is it mandatory? Then keep on reading.
The first step is always the outrage. This is a great way to cope with the feelings you're having at this moment. Scream, smash someTHING (never someone, then you're just a full blown psychopat)
After the outrage you will most likely feel a bit ashamed of what you just did, this is great, it means that you are feeling something else than frustation. Use this feeling and mix it with some other bad feelings you're having. Just FEEL those feelings for a while, minimum 30 minutes. You'll get why in a while.
You know all those bad feelings you just got from all the bad thoughts? Now it's time to use them! Think of some way you can hurt your process just as much as it hurted you. For example, if you've been coding for quite some time – remove it all, now you have to restart and the problem you just faced will most likely be replaced with another completely different.
Now you regret what you just did, right? That means you most likely wont do this again, and next time you want to have a meltdown you'll think back of this exact moment and realise why it's better to just box breath for a minute and keep on with your project instead. Good luck with what ever is upseting you :)