此处ValidationError为何不直接使用ValueError?谢谢~
学习是最好的投资!
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.
Let’s put it this way, mainly for the sake of friendliness, you use
ValueError
自然是可以的,但是在抛出异常的时候,我们只知道是值错误
,至于为什么会出现错误呢,我们利用ValidationError
继承ValueError
异常类的来告知,这里是验证错误
Customize exceptions to make the meaning of exceptions clearer.