Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-07-30 19:15:25

At 03:15 PM 7/30/2001, Lyell E. Haynes wrote:

> ...
>I am a little interested to hear what others have to say about using
>exception based failure mechanisms rather than return codes. Do you
>really need people to be putting every little socket function in a
>try/catch block in order to run safely? What about instances where an
>application will still want to continue running after a failure, just
>without network support. It seems to me to be simpler to just let the
>application check the return codes, rather than deal with the
>of setting it's own error codes in each catch block. Maybe some
>clarification on how this would work in this socket library. I know it's
>just the requirements spec, but I'm sure someone's already thought about
>how this would proceed.

Others have already done a nice job of explaining why the requirements
called for exception based error handling.

One last point: what happens if a programmer forgets error handling for a
function call?

With return code based error handling, the program will probably fail, and
may well do so in very hard to diagnose, or worse yet, silent ways.

With exception based error handling, the program may fail, but at least it
will be a noisy failure, and with reasonable tools the failure will be easy
to diagnose. Furthermore, if there was a higher level try/catch, the
program might even recover correctly.


Boost list run by bdawes at, gregod at, cpdaniel at, john at