One thing that might help involves dealing with the stressful situation. I've been in a similar situation when I was still pretty junior, and it caused me a lot of stress (and didn't end well because I handled it poorly). With more experience under my belt (9 years), I have some advice. Again, this is dealing with the source of the stress, which I think should help with the anxiety, if it works. Why I am saying junior? Because experience comes from work, so if you have 2 year of working experience, you're still junior. Non-working experience isn't a factor in this case. Junior has nothing to do with tech skill.
Senior developers have more experience, not necessarily sharper tech skills, and that's ok
This is something junior devs don't usually get, and it's frustrating to them. They see the senior dev's rusty skills and compare them to their own fresh, sharp skills, and assume the senior dev is a fraud who shouldn't be senior. But the senior dev isn't senior because of razor sharp tech skills (these dull with time as someone manages more and codes less). They're senior because they have years of experience from which they (hopefully) have learned pitfalls to avoid and critical soft skills that help them work effectively with management. Junior devs generally lack both, so they need senior devs to help steer them around pitfalls. One of the best junior devs I've ever seen still needed this. He let himself be steered (after resisting a bit), and it was a very good thing. If you notice management listening to senior dev, it doesn't necessarily mean there is a conspiracy afoot (in all seriousness, not meant as a slight at all). Managers look at experience first, tech skills second, and they likely (and very reasonably) respect and trust senior dev's judgement in looking at the big picture.
Don't fight the senior dev
Don't fight the senior dev. Don't. Every junior dev does (I did too), but it's folly. Yes junior devs have sharper tech skills, but they lack experience, and so usually don't know nearly as much as they think, and give the senior dev far less credit for knowledge than they should. And second, and very important, management trusts senior dev to steer the ship and to guide junior dev. Management expects junior dev to follow senior dev's lead. If junior dev refuses and says "but senior dev is an idiot, I know better because of XYZ priniciple", management won't think "wow, junior dev is right, senior dev is a fraud; I'll fire them and promote junior dev". Management thinks, "man, this junior dev is unmanageable and a big risk. I hope they fall in line soon, or we'll have to show them the door." I'm sure the last line isn't helpful for anxiety, but there's good news: there's probably time to turn the ship around! What should you do?
Submit to the senior dev's leadership!
Does the senior dev say to use GOTOs? Then use them. Raise concerns in a way that demonstrates humility and respects senior dev's experience, but still raise concerns (best done as genuine "I want to learn X" type questions, not "Isn't that a foolish way to do that?" type questions). Raise such concerns from the position of first assuming senior dev has a good reason and wanting to learn what it is, but communicating that you'll go along with what they say regardless, you just want to learn. I'll repeat: do what senior dev says. The only reason you should not do so is if you know for 100% certain that senior dev is not in any way in a leader or mentor role over you--not the tech lead, not over the project, not over the codebase, none of that. If your manager hasn't said this explicitly, then you should assume that they are. That's what senior devs are for.
Remember: your job is not to do things perfectly, your job is to get things done
Junior devs often don't realize this, but at the end of the day code must get done, and someone has to have responsibility for making decisions on how to architect the code, coding standards, etc. That is the responsibility of a senior dev, and quite likely of the senior dev in question. That means it's not your responsibility as junior dev. As long as you raise concerns in the right way (see above) when you have them, it's okay to write code in a way that doesn't make sense to you or feels like you're compromising code quality standards (with experience you'll learn about the tradeoff between cost, speed, and quality that makes this a given in the software industry; senior dev has probably already learned this lesson).
Why this will likely help
First it will hopefully repair the relationship between you and senior dev. Senior dev's responsibility is almost certainly to direct and mentor you. Right now you are accidentally making that difficult and stressful for senior dev, and you're seeing pushback from them (granted in a way that is not appropriate, but people are human). Repairing that relationship will make things less stressful for you, and reduce your anxiety, which should help your anxiety attacks. Bonus: it will also likely improve your image with your manager, which is important. And with time and experience you will start to see why all of these things are true, which will help with the anxiety as well, long term.
If this doesn't work
If you do all of this, fully, with complete humility and sincerity, going along with what senior dev says (and giving it a reasonable amount of time--at least a month or two), and they are still being abusive, then I agree with another poster that you need to look for another job. And of course none of this precludes the need to give priority to your mental and emotional health, nor does it assume that reducing your stress will fix everything, but it is a tool that should help, in addition to other steps.