比方說: Don't make assumptions about what the caller will do with the results of a function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do_something(Args) -> | |
case check_args(Args) of | |
ok -> | |
{ok, do_it(Args)}; | |
{error, What} -> | |
{error, What} | |
end. | |
error_report({error, What}) -> | |
format_the_error(What). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
do_something(Args) -> | |
case check_args(Args) of | |
ok -> | |
{ok, do_it(Args)}; | |
{error, What} -> | |
String = format_the_error(What), | |
%% Don’t do this | |
io:format("* error:~s\n", [String]), | |
error | |
end. |