Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b25250c7 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Add better error messages to Transition checks

Bug: 432258377
Test: Manual
Flag: EXEMPT trivial change
Change-Id: I9e97fad18f8c9cd32bee537fe98f47fbb0d527fe
parent 0dda1101
Loading
Loading
Loading
Loading
+26 −4
Original line number Diff line number Diff line
@@ -140,7 +140,15 @@ sealed interface TransitionState {
                check(
                    (fromContent == fromOrToScene && toContent == overlay) ||
                        (fromContent == overlay && toContent == fromOrToScene)
                )
                ) {
                    buildString {
                        appendLine("invalid ShowOrHideOverlay transition:")
                        appendLine("  fromContent: $fromContent")
                        appendLine("  toContent: $toContent")
                        appendLine("  fromOrToScene: $fromOrToScene")
                        appendLine("  overlay: $overlay")
                    }
                }
            }

            final override fun computeCurrentOverlays(): Set<OverlayKey> {
@@ -178,7 +186,9 @@ sealed interface TransitionState {
            abstract val effectivelyShownOverlay: OverlayKey

            init {
                check(fromOverlay != toOverlay)
                check(fromOverlay != toOverlay) {
                    "fromOverlay ($fromOverlay) and toOverlay ($toOverlay) cannot be the same"
                }
            }

            final override fun computeCurrentOverlays(): Set<OverlayKey> {
@@ -307,12 +317,24 @@ sealed interface TransitionState {
        private var _coroutineScope: CoroutineScope? = null

        init {
            check(fromContent != toContent)
            check(fromContent != toContent) {
                "fromContent ($fromContent) and toContent ($toContent) cannot be the same"
            }
            check(
                replacedTransition == null ||
                    (replacedTransition.fromContent == fromContent &&
                        replacedTransition.toContent == toContent)
            ) {
                buildString {
                    appendLine("invalid replacedTransition:")
                    appendLine("  fromContent: $fromContent")
                    appendLine("  toContent: $toContent")
                    appendLine(
                        "  replacedTransition.fromContent: ${replacedTransition?.fromContent}"
                    )
                    appendLine("  replacedTransition.toContent: ${replacedTransition?.toContent}")
                }
            }
        }

        /**