Why do I get an "ERR" while using my Nikon 50mm 1.4G lens?

It seems that you may have folded the opening lever on the camera body that makes contact with the opening lever on the back of the lens. Or you may have folded the lever on the back of the lens that pushes the camera lever to stop the opening just before the shutter opens. This is a fairly common problem when changing lenses in cameras that still use mechanical aperture control, rather than electric. It is easy to do if the lens is not aligned correctly when you rotate the camera lens.

You could also have pressed something on the misalignment that is causing some of the electrical contacts between the lens and the camera to not line up properly. However, normally in such a case, the lens would not work in any aperture that is not (perhaps) completely open.

For more information on mechanical opening levers and electrically controlled openings, see:
Nikon D5200 overexposed shots in "automatic" modes
This answer to What are the dangers of removing a lens while the camera is on?
What is an electromagnetic diaphragm?
Inconsistent exposure with the same configuration: why?
I changed the lens of my camera while my camera was on
Nikon D7000 thinks the lens aperture without CPU is always 16 and overexposes photos

For other possible causes with Nikon cameras, see:

Using an external battery with my Nikon d5200 caused failures
Nikon D90 mirror stuck
How to fix the Nikon D40x shutter without reassembly?