When to throw an exception?

后端 未结 30 2642
后悔当初
后悔当初 2020-11-21 23:48

I have exceptions created for every condition that my application does not expect. UserNameNotValidException, PasswordNotCorrectException etc.

30条回答
  •  自闭症患者
    2020-11-22 00:30

    the main reason for avoiding throwing an exception is that there is a lot of overhead involved with throwing an exception.

    One thing the article below states is that an exception is for an exceptional conditions and errors.

    A wrong user name is not necessarily a program error but a user error...

    Here is a decent starting point for exceptions within .NET: http://msdn.microsoft.com/en-us/library/ms229030(VS.80).aspx

提交回复
热议问题