CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Difference between Errors and Exceptions? (newbie)

  1. #1
    Join Date
    Jan 2017

    Smile Difference between Errors and Exceptions? (newbie)

    What's exactly the difference between an error and an exception(in detail if possible)

  2. #2
    Join Date
    Aug 2016

    Re: Difference between Errors and Exceptions? (newbie)

    An Error indicates serious problems that a reasonable application should not try to catch and an Exception indicates conditions that a reasonable application might want to catch. Unchecked exceptions are those exceptions that might not happen if everything is in order, but they do occur. Examples include ArrayIndexOutOfBoundException etc. Checked exceptions are generally those from which a program can recover & it might be a good idea to recover from such exceptions programmatically. Examples include FileNotFoundException For catching the exceptions we use try-catch clause.

    Example of Exception code:
    //connect to database 1
    catch(DatabaseConnctionException err){
    //connect to database 2
    //write the err to log

    Error are unchecked exceptions and the programmers do not have to do anything with it and it is a bad idea to try to catch errors with exceptions. The program cannot recover from the errors and the program should be allowed to terminate.
    Examples of error include OutOfMemoryError, StackOverflowError, etc.

  3. #3
    Join Date
    Jun 1999
    Eastern Florida

    Re: Difference between Errors and Exceptions? (newbie)

    Also read the API doc for the Error and Exception classes for more info.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)