You have to realise that throughout your professional pilot training, there are so many variables, so failing one element of your training is no big deal. Some of the finest pilots I have flown with have failed an element of their training at some stage.
Few people get through their training without a glitch. Life is full of ups and downs, but be positive. Once you have your CPL/IR it is similar to getting your driving licence. You have one hell of a lot to learn. With the right attitude you will be fine, so enjoy it.
All the best mate.