Example usage for io.netty.channel SimpleChannelInboundHandler channelRead

List of usage examples for io.netty.channel SimpleChannelInboundHandler channelRead

Introduction

In this page you can find the example usage for io.netty.channel SimpleChannelInboundHandler channelRead.

Prototype

@Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception 

Source Link

Usage

From source file:com.ibasco.agql.core.transport.handlers.ErrorHandler.java

License:Open Source License

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (log.isDebugEnabled()) {
        log.error("Unhandled exception caught within the pipeline {} for Channel {}, Id: {}", cause,
                ctx.channel(), ctx.channel().id());
        if (ctx.channel().hasAttr(ChannelAttributes.LAST_REQUEST_SENT)) {
            AbstractRequest request = ctx.channel().attr(ChannelAttributes.LAST_REQUEST_SENT).get();
            if (request != null && SocketChannel.class.isAssignableFrom(ctx.channel().getClass())) {
                Throwable ex = new ResponseException(request, cause);
                SimpleChannelInboundHandler responseRouter = ctx.pipeline()
                        .get(SimpleChannelInboundHandler.class);
                responseRouter.channelRead(ctx, ex);
                return;
            }/*  w  w  w. j  a v  a 2 s  .  c o  m*/
        }
        throw new TransportException(cause);
    }
}