catching errors from linked processes: simplest way?

Vance Shipley vances@REDACTED
Wed Apr 23 00:23:39 CEST 2003

It seems like a workable solution however I don't find it elegant.

It seems to me that since the problem you are trying to solve is an
error handling one it should be solved in the error handler.  If the
error handler needs to have knowledge of the structure of the code
to do the error handling the way you want then so be it.


On Tue, Apr 22, 2003 at 04:44:32PM -0500, Chris Pressey wrote:
}  Ah!  I think I see a compromise: notify the supervisor of the nature of
}  any potential upcoming errors.  So the code becomes something like:
}    foo(A, B) ->
}      supervisor:potential_error(only_applies_under_condition_a, [A,B]),
}      A = true, bar(B).
}  where supervisor:potential_error/2 sends a message to the supervisor,
}  which stores it in a dictionary using the pid the message came from as
}  the key, and which retrieves it when an error actually does occur.
}  The code is still fairly easy to read, and the supervisor doesn't need
}  to know about the structure of the code it's supervising, yet it can
}  know some details about what state the process was in when it crashed. 
}  Sweet!
}  -Chris

More information about the erlang-questions mailing list