From c5cea21a9ae01ac9bbe027c2a05dd983f3a6be98 Mon Sep 17 00:00:00 2001 From: i-ts Date: Thu, 12 Feb 2026 13:27:27 +0300 Subject: [PATCH] Add variable description to VariableMutationException commit_hash:db7d3a48789b7f9a2f20953be46f67255c900ed9 --- .../main/java/com/yandex/div/data/Variable.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/client/android/div-data/src/main/java/com/yandex/div/data/Variable.kt b/client/android/div-data/src/main/java/com/yandex/div/data/Variable.kt index 781d7998f..dddea2bde 100644 --- a/client/android/div-data/src/main/java/com/yandex/div/data/Variable.kt +++ b/client/android/div-data/src/main/java/com/yandex/div/data/Variable.kt @@ -304,10 +304,27 @@ sealed class Variable { this is DictVariable && from is DictVariable -> this.value = from.value this is ArrayVariable && from is ArrayVariable -> this.value = from.value this is PropertyVariable && from is PropertyVariable -> this.value = from.value - else -> throw VariableMutationException("Setting value to $this from $from not supported!") + else -> throw VariableMutationException( + "Setting value to ${describeVariable(this)} from ${describeVariable(from)} not supported!") } } + private fun describeVariable(variable: Variable): String { + val type = when (variable) { + is ArrayVariable -> "ArrayVariable" + is BooleanVariable -> "BooleanVariable" + is ColorVariable -> "ColorVariable" + is DictVariable -> "DictVariable" + is DoubleVariable -> "DoubleVariable" + is IntegerVariable -> "IntegerVariable" + is PropertyVariable -> "PropertyVariable" + is StringVariable -> "StringVariable" + is UrlVariable -> "UrlVariable" + } + + return "$type(name: '${variable.name}')" + } + @InternalApi @MainThread @Throws(VariableMutationException::class) @@ -325,7 +342,7 @@ sealed class Variable { is PropertyVariable -> value = newValue } } catch (_: ClassCastException) { - throw VariableMutationException("Unable to set value with type ${newValue.javaClass} to $this") + throw VariableMutationException("Unable to set value with type ${newValue.javaClass} to ${describeVariable(this)}") } }