Search in sources :

Example 1 with XpipeException

use of com.ctrip.xpipe.exception.XpipeException in project x-pipe by ctripcorp.

the class NettySlaveHandler method doChannelRead.

@Override
protected void doChannelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    ByteBuf byteBuf = (ByteBuf) msg;
    byteBufReadPolicy.read(ctx.channel(), byteBuf, new ByteBufReadAction() {

        @Override
        public void read(Channel channel, ByteBuf byteBuf) throws ByteBufReadActionException {
            try {
                redisMasterReplication.handleResponse(channel, byteBuf);
            } catch (XpipeException e) {
                throw new ByteBufReadActionException("handle:" + channel, e);
            }
        }
    });
}
Also used : ByteBufReadActionException(com.ctrip.xpipe.netty.ByteBufReadActionException) Channel(io.netty.channel.Channel) ByteBufReadAction(com.ctrip.xpipe.netty.ByteBufReadAction) ByteBuf(io.netty.buffer.ByteBuf) XpipeException(com.ctrip.xpipe.exception.XpipeException)

Example 2 with XpipeException

use of com.ctrip.xpipe.exception.XpipeException in project x-pipe by ctripcorp.

the class AsyncSendEmailCommandTest method testAsyncSendEmailCommand.

@Test
public void testAsyncSendEmailCommand() throws Exception {
    when(client.sendEmail(any())).thenThrow(new XpipeException("test exception"));
    CtripPlatformEmailService.AsyncSendEmailCommand command = new CtripPlatformEmailService.AsyncSendEmailCommand(generateEmail());
    command.setClient(client);
    CommandFuture future = command.execute();
    Assert.assertFalse(future.isSuccess());
    Assert.assertEquals("test exception", future.cause().getMessage());
}
Also used : CommandFuture(com.ctrip.xpipe.api.command.CommandFuture) XpipeException(com.ctrip.xpipe.exception.XpipeException) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Aggregations

XpipeException (com.ctrip.xpipe.exception.XpipeException)2 AbstractTest (com.ctrip.xpipe.AbstractTest)1 CommandFuture (com.ctrip.xpipe.api.command.CommandFuture)1 ByteBufReadAction (com.ctrip.xpipe.netty.ByteBufReadAction)1 ByteBufReadActionException (com.ctrip.xpipe.netty.ByteBufReadActionException)1 ByteBuf (io.netty.buffer.ByteBuf)1 Channel (io.netty.channel.Channel)1 Test (org.junit.Test)1