Welcome to e health forum.
Most likely you may have fainted due a vasovagal attack, which commonly occurs in extremely emotional or psychological situations.
People with panic attacks, eating disorders (which can result in low glucose levels) are more likely to have such episodes.
In case, you gained consciousness within minutes of the episode, and did not have any major persisting issues, you need not be worried about it anymore.
But if the loss of consciousness lasted for more than 15 minutes, and you have any form of neurological defecits (seizures, weakness, sensory defects, headache, nausea, vomiting, etc) you should consult with your doctor for a examination, a few tests and proper treatment of the underlying cause.