First thing is to clean the electrical contacts on camera body and lens.It may not be the lens but the body.
Call it luck of the draw or heng sway. Probably will get worse over time and suddenly will not work like before.Unless you are a hardcore diyer or electronic hobbyist who know how to repair competantly this will be beyond your capability. Other than changing the main/motherboard the alternative (if cost is cheap which is never the case) is to get another camera and sell epl7 if it is about 3 years old.
How I know? I bought a not working olympus and disassemble it to troubleshoot.
There is a common component that is used in the billions each year that industry experts say failure problem will always be present just the nature of the material, manufacturing process and handling, design, wear out and aging.
Hint..if this component's manufacturing yield is 98% (good parts in the billions) 2% potential defects means there are millions out there wating to fail! Remember it's the camera's body controls that give out the error message! This component comprise 30% of the BOM (bill of materials) of the camera electronics. PS you can't visually see the defect as it's internal and microscopic in dimension.
EDIT: If you test with another lens and it works...just take it as an intermittent one off thing it may not come or happen again. The choice is yours.Hope you have another lens or spare.