Boost logo

Boost :

From: Felipe Magno de Almeida (felipe.m.almeida_at_[hidden])
Date: 2005-12-12 10:19:23


On 12/12/05, Giovanni P. Deretta <gpderetta_at_[hidden]> wrote:

[snip]

>
> I've done exactly that in my network library (although it does support
> only synchronous behaviour). An optional error handler functor is
> passed to every functions that can generate an error. If no handler is
> passed a default handler is used that converts errors in exceptions.
> It works quite well. The user need to explicitly check for errors only
> if it wants to, else exceptions are used.

IMO, exceptions should be explicitly enabled if someone wants it.
Because exceptions very hardly will be what conceptually should be
used in this case. I think it may even be possible to have the three
ways:
- pass two functors, one being for error handling;
- pass one functor, this functor should have the asio::error parameter
(the way is being done now in asio);
- pass one functor, but exception being enabled. Though I dont know
how the functor should catch the exception that way...

As the last item seems to show, using exceptions not only isnt
efficient, it makes the code uglier. Using try and catch around a call
to receive the results to each different IO operation is too much
code. And if someone doesnt try catch? The exception will be caught by
the asio demuxer. What demuxer should do with it?
I'm against introduzing exceptions. But I agree it may be possible to
work a little more in the error handling. But, IMO, it should be like
adding helper classes for this, but not throwing exceptions.

Thanks,

--
Felipe Magno de Almeida

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk