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);
}