3 ms·
> which actually only means "things aren't working as expected" Exceptional circumstances, or exceptions for short, mean "things aren't working as expected due
by 9rx 2y ago
> which actually only means "things aren't working as expected"
Exceptional circumstances, or exceptions for short, mean "things aren't working as expected due to programmer error". In other words, a situation that theoretically could have been avoided by a sufficiently advanced compiler but that wasn't caught until runtime.
"things aren't working as expected" is vague enough to include errors, which are decidedly not exceptions. One might say a hard drive crash or the network failing isn't working as expected, but those situations are not exceptional.
> to make clear that it shouldn't be used where you might use exceptions in other languages.
Other languages are starting to learn that you shouldn't use exception handlers where you wouldn't use panic/recover, so I'm not sure there is a practical difference here.
- bazoom42 2y agoTerminology is a problem here. A crashed harddisk is clearly an exceptional circumstance. More specific terms is needed to distinguish errors in the code (eg divide by zero) from unpreventable errors like network failure.
- tored 2y agoIsn't that what we have exception hierarchies for?
- 9rx 2y ago> A crashed harddisk is clearly an exceptional circumstance. It is clearly not. It is very much something to anticipate. At sufficient scale, it is guaranteed that it will happen. There is nothing exceptional about it. > More specific terms is needed to distinguish errors in the code (eg divide by zero) from unpreventable errors like network failure. Luckily we have such terminology already: Exceptions (caused by mistakes in the code) and errors (caused by external faults).
- daveliepmann 2y agoIn what context is this terminology standardized?
- 9rx 2y agoTerminology is never standardized. Language doesn't work like that. How, exactly, does one manage to exist in this world and not know that...? However, outside of the Java world, which flips the terms around for some reason, this seems to be the prevailing usage. It is also the only usage that makes sense based on what seems to be the prevailing understanding of what "error" and "exceptional" mean. Java's "exceptional conditions" being the ones that you expect to happen regularly doesn't make sense, but was presumably an accident in naming that just so managed to stick. Of course, confusion is compounded by some language idioms using exception handling constructs to handle errors.
- daveliepmann 2y ago>Exceptional circumstances, or exceptions for short, mean "things aren't working as expected due to programmer error". Interesting. In Javaland this describes assertions, and the term exception is for operating errors, i.e. problems not necessarily attributable to programmer error, including your example of a network failure.
- ignoramous 2y ago> In Javaland this describes assertions, and the term exception is for operating errors, i.e. problems not necessarily attributable to programmer error Making matters more confusing in Javaland, Errors are separate from Exceptions, but both are Throwables. 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. https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html https://docs.oracle.com/javase/8/docs/api/java/lang/Error.ht... / https://archive.vn/i5F7B https://archive.vn/i5F7B
- chuckadams 2y agoErrors are not checked, the assumption being that most of the time you can’t do anything about them anyway.
- PeeMcGee 2y agoThis reminds me of one of my favorite SO answer-rants that reads like an angry Dr. Seuss rhyme: https://stackoverflow.com/a/36627158 https://stackoverflow.com/a/36627158 > Which of these are the "checked" exceptions? Throwables are checked exceptions, except if they're also Errors, which are unchecked exceptions, and then there's the Exceptions, which are also Throwables and are the main type of checked exception, except there's one exception to that too, which is that if they are also RuntimeExceptions, because that's the other kind of unchecked exception.
- jacinda 2y ago
- trallnag 2y agoIn Java I always see exceptions being used for stuff like validating HTTP requests