📜  laravel 发现或失败异常 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:44.758000             🧑  作者: Mango

代码示例1
use Illuminate\Database\Eloquent\ModelNotFoundException;

// Will return a ModelNotFoundException if no user with that id
try
{
    $user = User::findOrFail($id);
}
// catch(Exception $e) catch any exception
catch(ModelNotFoundException $e)
{
    dd(get_class_methods($e)); // lists all available methods for exception object
    dd($e);
}