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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top