Tuesday, September 15, 2015

Questions I ask Google, Episode 2

Are error codes the same as exception handling?


Oh boy, I did not expect the can of worms I opened with this question.

First, no, they aren't the same thing. And apparently, the differences between them is a subject of heated debate.

I was directed to a somewhat illuminating StackOverflow question that shed some light on where a large amount of people stand on the issue. It didn't quite answer my question, but I was able to garner some information from the responses.

An Error Code is a failsafe that is written into a program to report when something has gone wrong. An action to solve the issue must then be taken.

An Exception contains far more information than an Error Code, storing the state of the program as it was when the exception was triggered, and continuing (if possible) via an exception handler.

The debate is far more favored towards using Exceptions over Error Codes, and whenever I saw people who used error codes or "used to use" error codes, they typically were coding in C. Go figure.

I think the most interesting thing I found while looking for more information was this, though. What is that? That is the Wikipedia article describing the maiden flight of the Ariane 5, a rocket that was airborne for 37 seconds before an exception caused a vital part of the flight system to shut off. There are more details in the article, and this link will take you to the Wikipedia page describing, in further detail, what exceptions are and how the IEEE 754 Floating Point hardware standard played such a major part of that crash.

No comments:

Post a Comment