Home > Backend Development > PHP Tutorial > Yii2.0抛出异常问题

Yii2.0抛出异常问题

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:26:37
Original
1571 people have browsed it

<code>try {
    $model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
    throw new BadRequestHttpException($e->getMessage());
}
</code>
Copy after login
Copy after login

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

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

回复内容:

<code>try {
    $model = new ResetPasswordForm($token);
} catch (InvalidParamException $e) {
    throw new BadRequestHttpException($e->getMessage());
}
</code>
Copy after login
Copy after login

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

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

比如redis没连接上

try {
    $redis = new redis();
} catch (\Exception $e) {
    var_dump($e->getMessage());
}
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template