How to handle exception in decoders/handlers?
infectedrhythms
voodoo at videotron.ca
Fri Jun 19 13:42:17 EDT 2009
Hi, I have implemented a simple decoder and it works fine.
Now if there is an error I want to throw an exception catch and reply back
to the client, kind of like an HTTP 500 error.
So if the decoder fails it should write back to the client the error that
occurred.
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel,
ChannelBuffer buf) throws Exception {
... do stuff here...
throw new Exception("Errrorrrr!");
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e)
throws Exception {
super.exceptionCaught(ctx, e);
e.getChannel().write("Damn it Jim!"); <-- Throws a ClosedChannelException
}
--
View this message in context: http://n2.nabble.com/How-to-handle-exception-in-decoders-handlers--tp3121070p3121070.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list