4.4. LET IT CRASH
1072. We can have special processes which are only concerned with errorhandling.3. We can run the workers and supervisors on
di
c
erent
physical ma-chines.4. It o
d
en turns out that the error correcting code is
generic,
that is,generally applicable to many applications, whereas the worker codeis more o
d
en application specific.Point three is crucial—given that Erlang satisfies requirements R3 andR4 (see page 27) then we can run worker and supervisor processes ondi
c
erent physical machines, and thus make a system which tolerates hard-ware errors where entire processes fail.
4.4 Let it crash
How does our philosophy of handling errors fit in with coding practices?What kind of code must the programmer write when they find an error?The philosophy is
let some other process fix the error
, but what does thismean for their code? The answer is
let it crash
. By this I mean that inthe event of an error, then the program should just crash. But what is anerror? For programming purpose we can say that:
•
exceptions
occur when the run-time system does not know what todo.
•
errors
occur when the programmer doesn’t know what to do.If an exception is generated by the run-time system, but the program-mer had foreseen this and knows what to do to correct the condition that caused the exception, then this is not an error. For example, opening a filewhich does not exist might cause an exception, but the programmer might decide that this is not an error. They therefore write code which traps thisexception and takes the necessary corrective action.
Add a Comment