We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Catching Memcache Exception...

It doesn't seem like one can catch Memcache exception

    PHP Fatal error:  Uncaught exception 'Phalcon\Cache\Exception' with message 'Cannot connect to Memcached server' in phalcon/cache/backend/memcache.zep:113

This is what I am currently doing:

    $frontCache = new Data(array(
        'lifetime' => 0

    try {
        $service = new Memcache($frontCache, array(
            'host'       => $host,
            'port'       => $port,
            'persistent' => $persistent
    catch (\Exception $e)   // also tried with \Phalcon\Cache\Exception


    return $service;

There should be a way for phalcon/cache/backend/memcache.zep to pass on the exception back to caller so it can be handled in userland.

OR am I simply not catching it correctly?

The exception is passed back to the userland, it only shows the origin of the exception in the zephir code base. Print the backtrace to see whether the exception is really happening in the constructor.