Why do we have bloody exceptions if we need to double check every action taken?
Why do we have bloody exceptions if we need to double check every action taken?
I feel like in a language with exceptions, since throwing and catching happens inconsistently and haphazardly all around a code base, people are conned into thinking the exceptions will never happen. Usually one of two things happen:
1. The language is like java and it forces you to declare what exceptions you throw, so lazy people just put in lots of do-nothing catch blocks to silence the compiler.
2. The language doesn't have the "checked exceptions" concept, so people literally think no exceptions can happen. They just wait for the exception to make everything blow up.
Often when exceptions are handled, this lack of explicitness makes sure it's done at totally the wrong stack frame to make the judgement call about what to do about it. Then some people do dumb shit like try to catch things like stack overflow exceptions which should rightfully take down the process, and keep running. Not to mention that an exception is just a wacky concept, it's essentially a goto that crosses stack frames... Everyone criticizes goto, but few people will question exceptions...
If you're using a language with exceptions, your program will halt if it can't write. If you're using a language with checked exceptions, you'll have to write code to deal with any possible exception that can be thrown.