How can i handle SQL connection if could not connect to database , for example : if the connection was not successfull throw a 500 error or forward to a controller.
$di = new FactoryDefault();
$cf = new Ini("../config/config.ini");
#   Database connection
$di['db'] = function() use ($cf) {
    return new DbAdapter([
        "host"      => $cf->database->host,
        "username"  => $cf->database->username,
        "password"  => $cf->database->password,
        "dbname"    => $cf->database->dbname,
        "charset"   => $cf->database->charset
    ]);
};