How can I determine which exceptions can be thrown by a given method?

前端 未结 9 986
感情败类
感情败类 2020-11-30 22:41

My question is really the same as this one \"Finding out what exceptions a method might throw in C#\". However, I would really like to know if anyone knows of a way to deter

9条回答
  •  遥遥无期
    2020-11-30 23:12

    Unlike java C# does not have the concept of checked exceptions.

    On a macro level you should catch everything and log or inform the user of the error. When you know about the specific exceptions a method may raise then definetly handle that appropriately but be sure to let any other exceptions bubble up (preferably) or log them, otherwise you will have bugs that you will not be able to find and generally make life miserable for anyone hired to help reduce the bug list - have been there, not fun! :)

提交回复
热议问题