wxxcx_learn Exception Handling

It belongs to the basic framework, sub-level

Catch the exception, handle exceptions (logging, repair abnormal, returned to the client error), throw an exception

Global exception handler (AOP) for the same formatting error

try
{
$banner = BannerModel::getBannerByID($id);
}
catch (Exception $ex)
{
$err = [
'error_code' => '10001',
'msg' => $ex->getMessage()
];
return json($err);
}

Guess you like

Origin www.cnblogs.com/a276665092/p/10953554.html