Throw or return a tuple

orbitz <>
Sat Aug 13 06:23:05 CEST 2005

I find myself often confused about which to do, should I throw an 
exception when an error happens in a function or always go with 
returning {ok, Value} or {error, Whatever}.

Some people seem try to tell me that I should use {error, Value} and 
"get out of your OO mindset with exceptions".  But I think that is 
bull.  I don't see why exceptions should be purely considered OO and 
erlang has exceptions, why shouldn't I use them?  That seems like the 
talk of people afraid of change or something similar. The most 
convincing argument for me to use exceptions is because I want to be 
able to do:

foo(bar()) rather than {ok, V} = ...yadda.

What do people generally prefer? Are we moving towards more exceptions? 
  OTP seems to use exceptions for somethings and an error tuple for 


More information about the erlang-questions mailing list