Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Intercept Exception DI

Hi,

$di->set(
    'db', 
    function () use ($config) {
        return Factory::load($config->database);
    }
);

How can i redirect to the page500 if the connexion to the database failed ?

Can i add redirection here or it's only on models ?



92.2k
Accepted
answer

Redirecting using Phalcon's methods might be tricky here. I'd just do a plain PHP redirect. Or at the very least you could echo a message then exit.