Hi All,
I have touched upon exceptions earlier. However I am still not sure if I am handling them correctly.
try {
...
...
...
}catch(Exception $e){
if($prod === true) // In production mode
{
header("Location: exceptions/errors.php")
exit();
}
if($dev === true) // In development mode
{
echo $e->getMessage();
// & if needed log the errors / exceptions into a file.
exit();
}
}
I would like to ask if using the function header() to load the errors.php page is a good and safe practice. Or is there a better way to load the errors.php.
If I load the errors page as in the snippet, do I also have to log the errors myself in some files or is php going to do that in any case.
Any improvements or suggestions are welcome.
Thanks all !
P.S. Googling exceptions gives loads of information but seldom does it touch the issue of loading an errors page when an exception occurs.