You could handle it like this:
/// index.php
try {
// ...
echo $application->handle()->getContent();
}
catch(Phalcon\Application\Exception $e) {
if(preg_match('/^Module \'(.*?)\' isn\'t registered in the application container$/', $e->getMessage(), $match)) {
// You can get the attempted module name from the router:
echo '<pre>', var_dump($application->router->getModuleName()), '</pre>';
// Or the regexp match
echo '<pre>', var_dump($match[1]), '</pre>';
// Then handle it as you wish...
echo $application->handle('/error/e404')->getContent();
}
// ...
}
It's not very nice... but works :P