Just wanna share, i have the same issue for about 2-3 months ago, my camera suddenly stop working when i woke up, and i had this problem about a week or two until i try something that came up in my mind:
1. When the battery ran out, let say (1/2% remaining), i purposely open the camera app, and let the phone off by itself. After the phone off, i charged it for about 15 min in off condition, then after i switched on it, the camera miraculously working again.
2. Not so long after the camera back to normal, it started to error again, at this time i realized something on my phone, that i thought this error camera happen when, i open the camera when my phone got so hot/heated up until 40degree up or cold, in very cold condition in my case, for example in a room with AC, then i tried the previous solution but not working for me, as i frustated by it, then i just reboot my phone while open the camera app, and yes it back to normal, and it works until now when error coming again.
So in my case, the solution is, when the camera error, let your phone cool down/back to normal temperature, then open camera app, hold power button and reboot/restart from it, it works for me 100%, i hope it also works for you guys :)
Sorry for my bad english and my long text