So many questions

So I failed my one hour test and have to take the three hour one, I was just wondering is Gestational Diabetes from consuming too much sugar during pregnancy or can there be other reasons that causes it? I have been eating alot of sweets since about 20 weeks just one of my main cravings I guess but now feeling guilty. Also my belly measuring ahead.