Should I be a pattern matching each return value?

When I program in Erlang, should I check all return values ​​from function calls for success by using pattern matching, even if I do not intend to use the return value? Most of the Erlang APIs I've seen so far do not throw an exception on error (but return something like {error, Error}), so I need to check if the yes value returned is correct? Any exceptions to this when I really don't need to worry about it?

+5
source share
1 answer

This is a good programming style to minimize as soon as possible when something goes wrong. Everything that you performed after that will be performed with the system in an unknown state.

If you are not going to handle the error value and do something, you write your code for a successful case. As in the following little sad cycle:

life() ->
  ok = work(),
  ok = rest(),
  life().
+11
source

All Articles