search

Home  >  Q&A  >  body text

python - 关于flask中自定义ValidationError的疑问

此处ValidationError为何不直接使用ValueError?
谢谢~

PHPzPHPz2887 days ago345

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 17:39:00

    Let’s put it this way, mainly for the sake of friendliness, you use ValueError自然是可以的,但是在抛出异常的时候,我们只知道是值错误,至于为什么会出现错误呢,我们利用ValidationError继承ValueError异常类的来告知,这里是验证错误

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:39:00

    Customize exceptions to make the meaning of exceptions clearer.

    reply
    0
  • Cancelreply