Trapping exits means the exit signals are converted to messages before being sent to the process. Trapping exits is done on a per process basis. Execute process_flag(trap_exit, true).
in the process you want to be trapping exits.
Exit Type | Initiated by | Not trapping exits | Trapping exits |
---|---|---|---|
Normal |
|
Nothing |
Receives |
Normal |
|
Terminates normally |
Receives |
Abnormal |
|
Terminates abnormally |
Receives |
Kill |
|
Terminates abnormally |
Terminates abnormally |
Purpose | Expression to generate | try catch handling pattern |
trap_exit message |
---|---|---|---|
Stop execution because of runtime error |
|
|
|
Stop execution for any reason |
|
|
|
non-local return |
|
|
|
badmatch
-
pattern match error
badarg
-
BIF called with the wrong type
badarith
-
arithmetic error
undef
-
function not defined
function_clause
-
no matching function clause
if_clause
-
no matching if clause
case_clause
-
no matching case clause
Name | Type | Purpose | Function to Create / Example Calls |
Function to Destroy / Example Calls |
---|---|---|---|---|
Link |
Symmetrical |
Propagate exit signal from a process to all linked processes |
|
|
Monitor |
Asymmetrical |
Sends a message to the monitoring process when the monitored process dies |
|
|