Boyfriend couldn't get hard

So my boyfriend and I have been together for almost a year now and we decided we wanted to have sex. So (since we are still pretty young) I had to sneak him in my room. He was over and we cuddled and things escalated slowly. He started fingering me and I started giving him a hand job. After that we cuddled a little bit more and then he told me he got condoms before coming and he asked me if I wanted to have sex so I was like yeah. So we started to but then he couldn't get hard. He kept trying to but he couldn't. I told him it was okay and that we didnt have to do it tonight and we could just cuddle and he said okay but he seemed really upset and embarrassed. I felt really really bad. But is it something with me? Like is he not attracted to me or somethin? Or could it be something else?