Skip to content

Commit d18f979

Browse files
committed
Merge pull request AvaloniaUI#8252 from AvaloniaUI/safe-log-typed-adapter
Check if BindingValue actually has a value before logging an error
1 parent 5d360fa commit d18f979

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Avalonia.Base/Reactive/TypedBindingAdapter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ public void OnNext(BindingValue<object?> value)
3030
}
3131
catch (InvalidCastException e)
3232
{
33+
var unwrappedValue = value.HasValue ? value.Value : null;
34+
3335
Logger.TryGet(LogEventLevel.Error, LogArea.Binding)?.Log(
3436
_target,
3537
"Binding produced invalid value for {$Property} ({$PropertyType}): {$Value} ({$ValueType})",
3638
_property.Name,
3739
_property.PropertyType,
38-
value.Value,
39-
value.Value?.GetType());
40+
unwrappedValue,
41+
unwrappedValue?.GetType());
4042
PublishNext(BindingValue<T>.BindingError(e));
4143
}
4244
}

0 commit comments

Comments
 (0)