Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

What is the difference between an error and an exception?

OpenStudy (shadowfiend):

Typically errors are situations that you won't be able to recover from. For example, in Java, you can get an OutOfMemoryError. That's not really recoverable—you're out of memory, game over. On the other hand, exceptions are situations that you may well be able to recover from. For example, you can get an IndexOutOfBoundsException if you try to access past the end of an array. This means you didn't get the value you wanted from the array, but it doesn't necessarily mean your app has to crash.

OpenStudy (anonymous):

so calling pure virtual functions would be an exception?

OpenStudy (anonymous):

ah so exceptions are situations which may be handled gracefully, without crashing the whole system... but what if I get something like a StackOverflowException

OpenStudy (anonymous):

or would those ones be classified as 'fatal errors/exceptions'?

OpenStudy (anonymous):

from the http://docs.python.org/tutorial/errors.html and http://docs.oracle.com/javase/tutorial/essential/exceptions/definition.html I seem to get the idea that exceptions are simply runtime errors detected by the system, etc.

OpenStudy (shadowfiend):

Well the thing about stack overflows is that I believe they are recoverable. You just catch the exception and continue. And yes, errors are typically system-detected, mostly because the developer will rarely do something that shouldn't be caught. To quote http://docs.oracle.com/javase/7/docs/api/java/lang/Error.html : “An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath error, though a "normal" condition, is also a subclass of Error because most applications should not try to catch it.” But these two terms are occasionally used interchangeably, to be honest. The difference between the two tends to vary between languages.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!