execute custom function on database connection error

We you want to customise your Error Establishing Database Connection to something else then you need to create a file.

Here is the documentation for that

https://yoast.com/custom-wordpress-database-error-pages/