Browse Source

Merge pull request #8252 from AvaloniaUI/safe-log-typed-adapter

Check if BindingValue actually has a value before logging an error
pull/8267/head
Dan Walmsley 4 years ago
committed by GitHub
parent
commit
81bae5266f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/Avalonia.Base/Reactive/TypedBindingAdapter.cs

6
src/Avalonia.Base/Reactive/TypedBindingAdapter.cs

@ -30,13 +30,15 @@ namespace Avalonia.Reactive
}
catch (InvalidCastException e)
{
var unwrappedValue = value.HasValue ? value.Value : null;
Logger.TryGet(LogEventLevel.Error, LogArea.Binding)?.Log(
_target,
"Binding produced invalid value for {$Property} ({$PropertyType}): {$Value} ({$ValueType})",
_property.Name,
_property.PropertyType,
value.Value,
value.Value?.GetType());
unwrappedValue,
unwrappedValue?.GetType());
PublishNext(BindingValue<T>.BindingError(e));
}
}

Loading…
Cancel
Save