Hi Kirsty, sorry for the delay in getting back to you.
From the images it looks like your caterpillar may have been parasitized. Have a look at the link below and the parasitic wasp cocoons on this caterpillar look quite similar to the ones you have. If this is the case, it is nothing you did wrong, it just means a wasp had got there first and laid eggs on the caterpillar.
Kind Regards, Simon.
ECOLIBRARY :: DISPLAY - PARASITIZED CATERPILLAR:
For those of you who haven't been following I have been blogging about our pet caterpillar that died before it grew wings and flew.
Perhaps the picture below is not a cocoon (as we thought) but wasp pupae, poor caterpillar didn't stand a chance. Makes me feel a little better that we weren't poor caterpillar carers. Wished we'd waited for the wasps to emerge to see who was the culprit. I hope they were the bad bug eating wasps. At least some good may have come from our caterpillar tragedy. What a nasty survival technique, laying your eggs on another living thing then letting your young slowly kill it, could make a good movie.