try {
if(!isset($a)){
throw new Exception('缺少参数a','10002');
}
}catch{
$data['msg'] = $e->getMessage();
$data['code'] = $e->getCode();
return json_encode($data);
}
得到返回的错误提示:
下面是我们得知的获取exception中几个特定值的几个方法
官网找中的解释如下
try {
if(!isset($a)){
throw new Exception('缺少参数a','10002');
}
}catch{
$data['msg'] = $e->getMessage();
$data['code'] = $e->getCode();
return json_encode($data);
}
得到返回的错误提示:
下面是我们得知的获取exception中几个特定值的几个方法
官网找中的解释如下