Why do software engineers use error codes to describe issues instead of saying what is wrong?

In computer programming, an error code or return code could be both numeric or alphanumeric, which is used to determine the nature of the code and the reason behind its occurrence. Such errors are displayed when a machine is trying to perform something it is not able to. Therefore, the errors are then passed onto the error handlers, who look into the issue and try to determine the root cause. 

Furthermore, errors are not only displayed by computers only but also by consumer products as well. However, there is no definitive sequence or form of an error code. Different devices will display the same error in a different way. Some might use the decimal or hexadecimal style, whereas others will make use of alphanumeric codes.

The occurrence of error codes is quite normal. It does not mean that your computer or device has a serious problem. Most often, it could be solved by simply updating or reinstalling windows or programs. For instance, if you are trying to install a game that requires heavy graphics, your computer will display an error if it finds that your present graphics card does not carry the potential to support the game. In such a case, you will have to upgrade your graphics card in order to run the game.

Error codes report on the specific fault or symptom, not “what is wrong”.

An error code that translates to “Couldn’t connect to server” for example, means that for some reason the program couldn’t connect.

What exactly is wrong in that scenario? It could be that your internet connection is down, the server is down, both are down, you turned off your wifi antenna, there’s a memory leak in the program’s net code, the net code is poorly written, and many, many more possibilities.

So often, the error will be accompanied by common “what is wrong” causes of the error code “Check your internet connection, check your firewall, server busy/try again later, etc.”

Some of this comes from the early days of computers, when they had very limited memory. There wasn’t room for full error messages, so a number code was used which people could look up in a reference manual if necessary.

Now that we have discussed what error codes are and why they occur, it is important that we look at some of the most important error codes.

Syntax Errors

Just as humans communicate with each other using grammar rules, computers do it as well using computer languages. However, while humans get away with using less than perfect grammar, computers cannot. For instance, if we give a command to the computer to print a document Print (‘hello’) and accidentally forget to insert one of the parentheses, a syntax error will pop-up, not allowing the program to run. 

Logic Errors

One of the hardest errors to track down could be logic errors. From the outside, it may seem as everything is going as planned, but in reality, you have programmed it to do the wrong thing. Therefore, technically speaking, you are not getting the results you had expected. 

A famous example of logic error took place in 1999 when NASA lost a spacecraft due to miscalculations between English and American units. The software was coded, but it needed to work another way. 

Compilation Errors

Some programming languages require compilation steps. This is basically a process of converting your high-level language to a lower-level language for the computer to understand better. However, a compilation error may occur if the computer does not know how to convert your code into a lower-level code. 

Runtime Errors

Runtime errors could be pretty annoying for your end-user. This error arises when a user is trying to use your program. A program might be working perfectly on your machine, but it might display an error due to different configuration on the webserver. Therefore, this will stop someone from doing what they want to do while the system is running. 

Resource Code

The computer is designed to allocate a fixed amount of resources to run a program. If your code forces the computer to allocate excess resources, a resource code error will pop-up. It could be a tricky error to track down, but you can use several load-testing applications to find out the problem.

In conclusion, error codes are basically computer languages that help software engineers decipher the type of problem they are facing. By providing a number or, in some cases, an alphanumeric number, the software engineers are able to get straight down to the problem and maybe run a new code to fix the error.