code: public static ByteBuf toByteBuf(ChannelHandlerContext ctx, Throwable cause) {
          if (cause == null || cause.getMessage() == null) {
              return Unpooled.EMPTY_BUFFER;
          }
  
          return ByteBufUtil.writeUtf8(ctx.alloc(), cause.getMessage());
      }
docs: Creates a buffer containing the error message from the given exception. If the cause is
  {@code null} returns an empty buffer.