clear cache> followed by a soft reset (power phone off, wait a few seconds, power phone back on). If that does not work then try performing a partition cache clear which is good for clearing out software bugs without resorting to a factory reset which will require you to back up all of your data. You didn't specify which device you are using so I will put the instructions for the Note 9. The process is pretty much the same for most Samsung devices:
Hi there! Here is a link with some additional things to try in regards to the camera and the error that you're experiencing. https://thedroidguy.com/how-to-fix-camera-failed-error-on-your-samsung-galaxy-note-8-easy-steps-1084...
Unfortunately if none of the steps help, the next step would be to have the device service. If you would like to move forward with that process, feel free to send me a private message by clicking on my name and choosing the private message option.
Be sure to click " ✓ Accept as Solution" when you find an answer that works for you.