Why not use exceptions as regular flow of control?

后端 未结 24 1846
心在旅途
心在旅途 2020-11-21 07:30

To avoid all standard-answers I could have Googled on, I will provide an example you all can attack at will.

C# and Java (and too many others) have with plenty of ty

24条回答
  •  长发绾君心
    2020-11-21 08:14

    Apart from the reasons stated, one reason not to use exceptions for flow control is that it can greatly complicate the debugging process.

    For example, when I'm trying to track down a bug in VS I'll typically turn on "break on all exceptions". If you're using exceptions for flow control then I'm going to be breaking in the debugger on a regular basis and will have to keep ignoring these non-exceptional exceptions until I get to the real problem. This is likely to drive someone mad!!

提交回复
热议问题