by iamartnez · 12y ago · 0 comments
No it's not. The author touches on this:
Note the word intentional. In some cases, we do expect calls to fail. So we just handle it like everyone else would, but since we can emulate sum-types in Erlang, we can do better than languages with no concept of a sum-type.
So handle errors you expect explicitly and let the rest crash.
case user:authenticate(Username, Password) of
{ok, UserRecord} -> ...;
{error, notfound} -> ...;
{error, badpass} -> ...
end,No comments yet.