I'm trying to implement a simple health check page (to use with ELB). It connects to the database, loads a model, and returns a 200 status code if everything is OK, and a non 200 status code if something goes wrong.
The problem that I am having is that Code Igniter seems to return a 200 status code when non fatal PHP errors are encountered. Can I modify that behaviour (if possible only for a specific controller)?
To be clear, currently I get a 200 status code even when there's an error:
A PHP Error was encountered Severity: Warning Message: mysqli::real_connect(): (HY000/1045): Access denied for user 'X'@'Y' (using password: YES) Filename: mysqli/mysqli_driver.php Line Number: 202
I want to return a non 200 in this case (bc that's what makes sense for a health check page).
Any ideas?