I am using the PHP copy function in part of my program, where the parameters of the function depend on user input. I am trying to avoid the default php error message if they include a path that the function cannot use, and output a custom message like shown below. I am new to handling errors/ exceptions. I am still getting the php default error message instead of the custom 'Path was incorrect!' using the method below.
What I tried:
try{
copy($webImagePath, $destinationPath);
}
catch(Exception $e){
echo 'Path was incorrect!';
}