diff --git a/shared/src/main/scala/pine/RenderContext.scala b/shared/src/main/scala/pine/RenderContext.scala index 7dd02a3..235382c 100644 --- a/shared/src/main/scala/pine/RenderContext.scala +++ b/shared/src/main/scala/pine/RenderContext.scala @@ -33,13 +33,15 @@ class NodeRenderContext extends RenderContext { def commit[T <: Singleton](tag: Tag[T]): Tag[T] = { val r = render(tag) - if (r.isEmpty) throw new Exception("Root node cannot be removed") - else if (diffs.exists { - case (TagRef.Each(_), _) => false - case (TagRef.Opt (_), _) => false - case _ => true - }) throw new Exception(s"Some diffs could not be applied: $diffs") - assert(r.length == 1) - r.head.asInstanceOf[Tag[T]] + if (r.length != 1) throw new Exception("The root must consist of exactly one node") + else { + if (diffs.exists { + case (TagRef.Each(_), _) => false + case (TagRef.Opt(_), _) => false + case _ => true + }) throw new Exception(s"Some diffs could not be applied: $diffs") + + r.head.asInstanceOf[Tag[T]] + } } }