I got stuck working in an error logging piece that I'm working on, and ultimately it devolved into the following:
$errorMsg = 'No Errors Detected';
try{
nonexistentfunction(); //Basically something here will not work
}catch(Exception $e){
$errorMsg = 'Oh well, something went wrong';
}finally{
$this->logger->log($errorMsg);
}
However, every time the logger logs the message 'No Errors Detected' while it should be logging 'Oh well, something went wrong' because I'm throwing an exception (method not found in this example, but any exception can occur).
How do I get the code in the catch() block to execute? It doesn't seem to execute at all!