The Right Approach to Exceptions
Jim Hewes
jimhewes at gmail.com
Sun Feb 19 15:18:57 PST 2012
On 2/19/2012 10:48 AM, address_is at invalid.invalid wrote:
>
> I guess "transient" is more descriptive.
>
> Andrei
I suppose “transient” mingles with recoverability and may get confused
with it. But the interrelated issue that comes to mind for me is whether
a “failure” is a common and typical result of the particular operation
or not.
I'm thinking of the example of acquiring a mutex. Because the nature of
a mutex is to prevent two parties from using a resource at the same
time, getting a result of “mutex already in use” is a normal and
expected result and probably should not throw an exception. It's
transient in that you can try again and it might work. But this behavior
is already built in because you can provide a timeout argument which
means, “keep trying until this much time elapses, then give up”.
Perhaps a network connection would be different because when you send a
packet, you expect it to get where it's going. That would be normal
program flow. Otherwise it's an error and an exception.
Jim
More information about the Digitalmars-d
mailing list