We handle this with redundancy.
Message Passing vs Shared Variable
Shared variable interactions are implicit, meaning that they exist by convention, not in code. However, MP is explicit, to from channels.
Therefore it is easier to keep track of message passing, therefore making it “better”.
What do we need for error handling
Error handling is not
err = doA(&a)
if err:
return errBecause we do not handle anything. We simply pass it up to a higher abstraction.
Proper error handling requires undoing. However doing this with returns and exceptions produce ugly code.
The best way is Control Flow Mechanisms
Robust error detection
- We need to detect errors, “even the ones we can’t detect.” For example cosmic rays.
- Error returns are good for known errors
- However, there is no error return for bugs, race conditions, anything timing-related.
- Tests are (by their nature) deterministic, therefore they are bad at random events.
A solution for this is Success Detection
A way to crash the program
This should we easily implemented.
A restart mechanism
For example Process Pair, or Supervisor depending on your needs.
Optional: A resuming mechanism
This is a way to not lose all progress. This is how the Process Pair in README Ex4 was implemented.
Dump
- When we get errors, our solution is usually try again, or crash.