Frustrated with weight gain

Ch
My dr told me today at my 31 week check up that I've gained too much weight and need to stop eating carbs 😭 I know I've gained a lot of weight, 40 lbs already but I really just wanted to cry the whole time he was telling me! My husband does most of the cooking now so he makes pasta a lot cause it's easy, I'm going to stop eating pasta but I just wish the dr told me in a nicer wayÂ