What factors should be taken into consideration when writing a custom exception class?

后端 未结 7 943
甜味超标
甜味超标 2020-12-29 15:38

When are custom Exception classes most-valuable?
Are there cases when they should or should not be used? What are the benefits?

Related

7条回答
  •  滥情空心
    2020-12-29 16:26

    I'm a bit of a minimalist and will only create a custom exception if there is calling code that must explicitly react to the particular condition that occured. For all other situations I'll use the most appropriate .NET library exception. E.g. ArgumentNullException, InvalidOperationException

提交回复
热议问题