Exception Handling: Custom Exception Benefits

My exception handling skills are very primary, and I'm always very confused about how I should use them, and not the way / syntax. I am currently using C # (if different things apply to it).

My question is, what are the benefits of creating your own Exception class when developing an application? Compared to throwing a standard exception class exception. Basically, what is a healthy exception practice in your application.

Or, if not benefits, then disadvantages?

+5
source share
7 answers

, ( ) , , - .

, , . :

- , , . , .NET Framework , - , . , , . , , . , , . InnerException , .

+5

, , , .

", - ", .

, , , .

+3

, , , . , . .

+2

- , , . .

, , .

  • CleanFailureException - - , . , - , , . , DoSomething, TrySomething False. , .
  • StateDisturbedException - - , . , , , , . , ( ). , , CleanFailureException.
  • TargetStateCorruptException - , , , , , . , , CleanFailureException.
  • ParentStateCorruptException - , - , "" , . , , " CleanFailureException".
  • SystemOnFireException

, , , , . , . people , , Exception.Message.

+2

, , , , .

+1

, , , bool. , :

, ?

, , , , , , , , . , , .

+1

, , - , .

, , , "TooFewRecipients", , .

System.Exception

, , - , , . MSDN

+1

All Articles