In many cases, the 'camera failed' error occurs because the Camera app has got itself into a bit of a mess. You can often solve that with a fairly simple bit of housekeeping. Go into Settings > Applications Manager and then swipe left for All Apps. Scroll down to the Camera app and tap on it. Now tap on Force Stop, then Clear Cache, then Clear Data. Don’t worry: this won’t delete any of your photographs, but it will delete your camera’s settings so you’ll need to set those again. Reboot your phone and see if that worked.
If it didn’t, step two is to clear the cache partition. To do that, turn off your phone and then press and hold Volume Up, Power and Home. Once the phone vibrates, let go of Power but keep the other two buttons pressed. Once you see the Android Recovery screen, navigate to Wipe Cache Partition using the volume down key and use Power to select it. This won’t delete your data but it should reset the app’s cache, which should solve the problem.
Nothing? Time for the nuclear option: a factory reset. Make sure you take backups of anything you need first, as this will return your phone to factory-fresh condition without any of your stuff on it.
Still no joy? Dump the app altogether and try the excellent Google Camera (KitKat or later required) or one of the many wonderful third-party camera apps out there. Read the reviews carefully though: some camera apps are better than others. There's no point in installing a duffer.