Hi,

When using the threaded router with the SpinoffSimpleReadThread() I've 
just realised that Barry::Error exceptions aren't caught by DoRead or 
the thread function. This means that if a 
SocketDataHandler::DataReceived() method throws something such as 
Barry::BadSize then it'll lead to a terminate as it's an uncaught exception.

I think there are two options here, forbid 
SocketDataHandler::DataReceived() implementations from throwing 
Barry::Error exceptions or catch all Barry::Error exceptions in 
SocketRoutingQueue::DoRead(). I would favour the latter, calling the 
appropriate SocketDataHandler::Error() with something like the following:

if( sdh ) {
        // unlock&  let the handler process it
        lock.unlock();
-       sdh->DataReceived(*buf.get());
+       try {
+               sdh->DataReceived(*buf.get());
+       }
+       catch( Barry::Error&be ) {
+               // Pass the error direct to the handler,
+               // this saves the need for every data handler
+               // implementation to wrap the method with
+               // a try catch.
+               sdh->Error(be);
+       }
        return;
}

But I can see that having SocketDataHandler implementations handling their own 
errors entirely internally might be a better idea.

Regards,

Toby



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Barry-devel mailing list
Barry-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/barry-devel

Reply via email to