Browse Source

Log meaningful message for AggregateException.

pull/691/head
Steven Kirk 10 years ago
parent
commit
92ebb7f6d8
  1. 2
      src/Avalonia.Base/AvaloniaObject.cs
  2. 23
      src/Avalonia.Base/Utilities/ExceptionUtilities.cs
  3. 3
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlBindingTests.cs

2
src/Avalonia.Base/AvaloniaObject.cs

@ -670,7 +670,7 @@ namespace Avalonia
"Error binding to {Target}.{Property}: {Message}", "Error binding to {Target}.{Property}: {Message}",
this, this,
property, property,
notification.Error.Message); ExceptionUtilities.GetMessage(notification.Error));
} }
} }
} }

23
src/Avalonia.Base/Utilities/ExceptionUtilities.cs

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Avalonia.Utilities
{
internal static class ExceptionUtilities
{
public static string GetMessage(Exception e)
{
var aggregate = e as AggregateException;
if (aggregate != null)
{
return string.Join(" | ", aggregate.InnerExceptions.Select(x => x.Message));
}
return e.Message;
}
}
}

3
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlBindingTests.cs

@ -43,7 +43,8 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
pv.Length == 3 && pv.Length == 3 &&
pv[0] is ProgressBar && pv[0] is ProgressBar &&
object.ReferenceEquals(pv[1], ProgressBar.ValueProperty) && object.ReferenceEquals(pv[1], ProgressBar.ValueProperty) &&
(string)pv[2] == "Could not convert FallbackValue 'bar' to 'System.Double'") (string)pv[2] == "Object reference not set to an instance of an object. | " +
"Could not convert FallbackValue 'bar' to 'System.Double'")
{ {
called = true; called = true;
} }

Loading…
Cancel
Save