PHP question about try/catch and xdebug
I tried using try/catch statements in my PHP code, but they don't appear to be working.
I recently enabled xdebug so I could walk through code with PHPStorm -
Does anyone know if there's a conflict? Is it possible xdebug is trapping the errors before the catch statement can get to them?
I'm fairly new to all this so it's entirely possible I just missed something - any guidance would be appreciated.
- Jack
Edit: Some sample code is likely helpful...
I came up with the simplest scenario I can think of -
I should be able to deal with this in the Catch code, but that never executes and instead xdebug displays an warning and the rest of my code runs.
public function testTryCatch(){
try {
$result = 1/0;
}
catch (Exception $e) {
echo "General Exception: /n";
var_dump($e);
var_dump($e->getMessage());
}
}
Please sign in to leave a comment.
Hello Jack,
Does this help: http://stackoverflow.com/questions/2904105/disabling-xdebugs-dumping-of-caught-exceptions ?
Regards,
Kirill
Perfect - Thanks Kirill!