Hello!

Do I have to handle exceptions when creating an application? And what is good about their presence, and their absence is fraught with?

Thank.

    2 answers 2

    Not necessarily, but desirable. Their presence and trapping will allow you to quickly find and / or process / correct errors without launching the application. In the absence of exception handling, the application will simply stop its operation when a critical error (2/0, for example) appears.

    Wikipedia article.

    • I would also recommend reading the chapter from the Trey Nash Accelerated C # 2010 book "Exception Handling and Exception Safety". - Eugene Cheverda

    If the application does not handle the exception itself, then the default handler will be called, which in most cases will cause the application to crash. Depending on the application, this may or may not be acceptable.

    The exceptions themselves make it easier to handle errors when you don’t need to explicitly track return codes from functions.