Home > Q&A > body text
此处ValidationError为何不直接使用ValueError?谢谢~
PHP中文网2017-04-17 17:39:00
Let’s put it this way, mainly for the sake of friendliness, you use ValueError自然是可以的,但是在抛出异常的时候,我们只知道是值错误,至于为什么会出现错误呢,我们利用ValidationError继承ValueError异常类的来告知,这里是验证错误
ValueError
值错误
ValidationError
验证错误
Customize exceptions to make the meaning of exceptions clearer.