Yii2.0抛出异常问题



 try {
    $model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
    throw new BadRequestHttpException($e->getMessage());
}

这是 Yii2.0 中的一段代码。

RT,在实际项目开发中,什么情况下需要抛出异常并进行处理?

yii php yii2

日、后再见 9 years, 11 months ago

比如redis没连接上


 try {
    $redis = new redis();
} catch (\Exception $e) {
    var_dump($e->getMessage());
}

1st小孩 answered 9 years, 11 months ago

Your Answer