I've already thoroughly documented my panic attacks from smoking weed elsewhere here. In a nutshell it's exactly as GreeLee just described. If you're not in the right frame of mind, weed doesn't help you relax, it only amplifies the stresses you've got in your life at that moment.
I was an avid pot smoker for more than 10 years. Rarely a day went by where I didn't have a few hits from the bong or smoke a joint or three, even at work. It was never a problem. Then something snapped one day and what was an enjoyable pastime became a nightmare. I now only occasionally smoke, usually when I'm chilling with friends having a few drinks on holiday or something far far away from any of life's worries and never, ever, in front of the computer.
My advice to you would be to chill out on the weed and caffeine and any other stimulants. Eat right, SLEEP RIGHT, and get some exercise. Even just a brisk walk in the fresh air and sunshine for an hour a day will clear your mind and do you a world of good. Fuck the Xanax, that shit turns you into a zombie and isn't the answer to your long term health.