[phobos] isemail error handling

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 4 15:46:50 PST 2011


On Friday, March 04, 2011 15:25:05 Jesse Phillips wrote:
> Is there a reason to make them exceptions? The whole point is to tell
> you if it is or is not a function. I would not consider it an error
> code more a "reason code" (why it wasn't an email address).

Those aren't exceptions then. An exception would be for an error of some kind in 
running your function. But there is no error in running your function. It's 
validly running and telling you that the input was not a valid e-mail address. 
There's no error there. So, it looks like it either needs an additional out 
parameter or to return a tuple with whether the address is valid and the reason.

Since there are likely a lot of cases that the programmer doesn't care why the 
e-mail address is invalid, you should probably create two versions of the 
function (probably one which wraps the other), where one has an out parameter 
for the reason that the address is invalid and the other doesn't.

- Jonathan M Davis


More information about the phobos mailing list