Is it a good or bad idea throwing Exceptions when validating data?

后端 未结 14 929
你的背包
你的背包 2020-12-07 16:27

When validating data, I\'ve gotten into a habit of doing the following:

Note: I don\'t really have individual booleans for each check. This is just

14条回答
  •  粉色の甜心
    2020-12-07 17:06

    I generally agree with the "exceptions should be exceptional" rule, but I might make an exception (ha!) for Python, where it can be both efficient and considered good practice to use try ... except to control flow.

    See Using Exceptions For Other Purposes, for example.

提交回复
热议问题