In namespaced context the Exception class needs to be prefixed with global prefix operator.
<?php
namespace hey\ho\lets\go;
class MyClass
{
public function failToCatch()
{
try {
$thing = somethingThrowingAnException();
} catch (Exception $ex) {
// Not catched
}
}
public function succeedToCatch()
{
try {
$thing = somethingThrowingAnException();
} catch (\Exception $ex) {
// This is now catched
}
}
}