Handle single/multiple exceptions from avalonia's data error subsystem in ErrorDescriptorToBorderColorConverter.cs
MODIFY
WalletWasabi.Gui/Converters/ErrorDescriptorToBorderColorConverter.cs
WalletWasabi.Gui/Converters/ErrorDescriptorToBorderColorConverter.cs
@@ -11,23 +11,40 @@ namespace WalletWasabi.Gui.Converters
{
public class ErrorDescriptorToBorderColorConverter : IValueConverter
{
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ private ErrorDescriptor UndefinedExceptionToErrorDescriptor(Exception ex)
{
- if (value is IEnumerable<object> rawObj)
+ var newErrDescMessage = ExceptionExtensions.ToTypeMessageString(ex);
+ return new ErrorDescriptor(ErrorSeverity.Warning, newErrDescMessage);
+ }
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var descriptors = new ErrorDescriptors();
+ if (value is IEnumerable<object> rawObj)
+ {
foreach (var error in rawObj.OfType<ErrorDescriptor>())
{
descriptors.Add(error);
}
- return GetColorFromDescriptors(descriptors);
+ foreach (var ex in rawObj.OfType<Exception>())
+ {
+ descriptors.Add(UndefinedExceptionToErrorDescriptor(ex));
}
-
+ }
+ else if (value is Exception ex)
+ {
+ descriptors.Add(UndefinedExceptionToErrorDescriptor(ex));
+ }
+ else
+ {
return null;
}
+ return GetColorFromDescriptors(descriptors);
+ }
+
private SolidColorBrush GetColorFromDescriptors(ErrorDescriptors descriptors)
{
if (!descriptors.HasErrors)

Handle single/multiple exceptions from avalonia's data error subsystem in ErrorDescriptorToBorderColorConverter.cs