Debug.Assert vs Exceptions

前端 未结 8 1145
面向向阳花
面向向阳花 2020-12-13 21:03

Surprisingly I was only able to find one previous question on SO about this subject, and I\'d just like to get the community \"Vote of Confidence\" (or not!) on my approach.

8条回答
  •  佛祖请我去吃肉
    2020-12-13 21:50

    It depends on language, is assert if you syntax sugar then you should use it. however in Java asserts need to be turn on for this to work, so exception is better. However its always better to have specific exception, so here it should be IllegalStateException.

提交回复
热议问题