Skip to content

Commit 4f0fd8f

Browse files
committed
RenderContext: Remove assertion from commit()
1 parent 71fe45d commit 4f0fd8f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

shared/src/main/scala/pine/RenderContext.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ class NodeRenderContext extends RenderContext {
3333

3434
def commit[T <: Singleton](tag: Tag[T]): Tag[T] = {
3535
val r = render(tag)
36-
if (r.isEmpty) throw new Exception("Root node cannot be removed")
37-
else if (diffs.exists {
38-
case (TagRef.Each(_), _) => false
39-
case (TagRef.Opt (_), _) => false
40-
case _ => true
41-
}) throw new Exception(s"Some diffs could not be applied: $diffs")
42-
assert(r.length == 1)
43-
r.head.asInstanceOf[Tag[T]]
36+
if (r.length != 1) throw new Exception("The root must consist of exactly one node")
37+
else {
38+
if (diffs.exists {
39+
case (TagRef.Each(_), _) => false
40+
case (TagRef.Opt(_), _) => false
41+
case _ => true
42+
}) throw new Exception(s"Some diffs could not be applied: $diffs")
43+
44+
r.head.asInstanceOf[Tag[T]]
45+
}
4446
}
4547
}

0 commit comments

Comments
 (0)