Surprise!

So a week ago I got my period after not having it since September and I was at school and I felt something come out of my vagina so I went to the bathroom and I looked at it but it didnt look like any normal tissue coming out, so luckily I was alone in the bathroom and so I cleaned it up a little and I noticed that it was a sac and something was in it and so I instantly realized that I had a miscarriage. I told my boyfriend because i thought he should know instead of me keeping it a secret but my heart broke. I cant stop thinking about it. Am I over reacting? Did I do something wrong?