Massive stars undergo a violent death when the supply of nuclear fuel in their cores is exhausted, resulting in a catastrophic ``core-collapse'' supernova. Such events are usually only detected at least a few days after the star has exploded. Observations of the supernova SNLS-04D2dc with the Galaxy Evolution Explorer space telescope reveal a radiative precursor from the supernova shock before the shock reached the surface of the star and show the initial expansion of the star at the beginning of the explosion. Theoretical models of the ultraviolet light curve confirm that the progenitor was a red supergiant, as expected for this type of supernova. These observations provide a way to probe the physics of core-collapse supernovae and the internal structures of their progenitor stars.