Frage

We have a problem in our staging environment. The try-catch blocks aren't working as expected, and we couldn't find why.

We are only running this test snippet:

try {
    throw new Exception('teste');
} catch (Exception $e) {
    echo $e->getMessage(); exit;
}

Running that, we got an "Uncaught exception" error, and not the exception message. We're not using namespaces.

Does anybody know what's going on?

We're using PHP 5.4.17, Apache 2.2.2, RHEL linux.

War es hilfreich?

Lösung

Found the answer!

This is a bug in eAccelerator. I just disabled it, and the code magically worked just fine.

I saw it in this thread: PHP5: Why is try/catch failing?

I had googled it before, I just haven't found this thread. Looks like upgrading the extension solves the problem as well.

Thank all of you that answered this question.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top