I am doubt of PHP's try catch mechanism about why when l using try catch to process the error, but PHP still show the default error message
For example, l'm using PHP excel lib to parse the xls
file, but l wanna to print a user friendly error output, like
{code:1, msg:"some error"}
So l do these:
try {
return $this->getJSON($fileName);
}catch (Exception $e){
$f = fopen('/' . trim(ROOT_DIR, '/\\') . '/file/Excel_error', 'wb');
fwrite($f, $e);
$split_content = "\n\n-------------------------------------\n\n";
fwrite($f, $split_content);
fclose($f);
echo json_encode(array(
"code" => 10000,
"msg" => "Excel parse error",
"files"=>null
));
}
l want to log the error file and output my custom msg to front-end, but it doesn't work, When l trigger a error/warning or others, PHP still show the PHP Error
/E_WARINING
... like follow screenshot
PS: l process the file in getJSON()
, this function is my entrance.