When the Onan shuts itself down there will be a series of flashes on the button at the generator. That's the error codes referred to by a previous poster. You count the number of flashes then go to the Onan site and reference them in an online manual.
I just had the same problem with a brand new Onan. Turns out the generator detected no output voltage being produced so it is designed to shut down under that circumstance as well as others mentioned.
Went to a Cummins dealership and they found the problem in 5 minutes. A shorted out wire nut. The error code I gave them helped immensely to zero in and charges were minimal.