11.1 Terminology
Errors can roughly be divided into four different types:
- Compile-time errors
- Logical errors
- Run-time errors
- Generated errors
A compile-time error, for example a syntax error, does not cause much trouble as it is caught by the compiler.
A logical error is when a program does not behave as intended, but does not crash. An example is that nothing happens when a button in a graphical user interface is clicked.
A run-time error is when a crash occurs. An example is when an operator is applied to arguments of the wrong type. The Erlang programming language has built-in features for handling of run-time errors.
A run-time error can also be emulated by calling erlang:error(Reason) or erlang:error(Reason, Args).
A run-time error is another name for an exception of class error.
A generated error is when the code itself calls exit/1 or throw/1. Notice that emulated run-time errors are not denoted as generated errors here.
Generated errors are exceptions of classes exit and throw.
When a run-time error or generated error occurs in Erlang, execution for the process that evaluated the erroneous expression is stopped. This is referred to as a failure, that execution or evaluation fails, or that the process fails, terminates, or exits. Notice that a process can terminate/exit for other reasons than a failure.
A process that terminates emits an exit signal with an exit reason that says something about which error has occurred. Normally, some information about the error is printed to the terminal.