private void callHandlerAdded(final AbstractHandlerContext ctx) {
        try {
            ctx.handler().handlerAdded(ctx);
        } catch (Throwable t) {
            boolean removed = false;
            try {
                remove(ctx);
                removed = true;
            } catch (Throwable t2) {
                if (LOG.isWarnEnabled()) {
                    LOG.warn("Failed to remove a handler: {}, {}.", ctx.name(), StackTraceUtil.stackTrace(t2));
                }
            }

        fireExceptionCaught(null, new PipelineException(
                ctx.handler().getClass().getName() +
                        ".handlerAdded() has thrown an exception; " + (removed ? "removed." :  "also failed to remove."), t));
        }
    }
Most of the code references the pipeline design of
<a href="https://github.com/netty/netty">Netty</a>.

@author jiachun.fjc
jraft-rheakv/rheakv-core/src/main/java/com/alipay/sofa/jraft/rhea/util/pipeline/DefaultPipeline.java