My first inclination is to assume that a lens error is the intermittent problem itself, but first, there is a more likely possibility, lack of sufficient power. Remove the batteries, check the pins or connectors in the battery compartment, and make sure that they are positioned correctly to contact the battery. Then use a q-tip with alcohol to clean and dry them.
It is also a known issue that digital cameras circuitry can also become much more sensitive to the lower power level produced, as they begin to age, if you have been using the same rechargeable batteries, for the life of the camera, then the power capacity of the battery may not be high enough anymore to handle the increased load. New batteries may be the answer.