Skip to content

Commit

Permalink
RenderContext: Remove assertion from commit()
Browse files Browse the repository at this point in the history
  • Loading branch information
tindzk committed Mar 20, 2018
1 parent 71fe45d commit 4f0fd8f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions shared/src/main/scala/pine/RenderContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}
}
}

0 comments on commit 4f0fd8f

Please sign in to comment.