<commit_before>using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using WalletWasabi.Models;
using WalletWasabi.Logging;

namespace WalletWasabi.Gui.Converters
{
	public class ErrorDescriptorToBorderColorConverter : IValueConverter
	{
		private ErrorDescriptor UndefinedExceptionToErrorDescriptor(Exception ex)
		{
			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);
				}

				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)
			{
				return null;
			}

			var highPrioError = descriptors.OrderByDescending(p => p.Severity).FirstOrDefault();

			if (ErrorSeverityColorConverter.ErrorSeverityColors.TryGetValue(highPrioError.Severity, out var brush))
			{
				return brush;
			}
			else
			{
				return null;
			}
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}
<commit_msg>Fix error descriptor to border color converter.<commit_after>using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using WalletWasabi.Models;
using WalletWasabi.Logging;

namespace WalletWasabi.Gui.Converters
{
	public class ErrorDescriptorToBorderColorConverter : IValueConverter
	{
		private ErrorDescriptor UndefinedExceptionToErrorDescriptor(Exception ex)
		{
			var newErrDescMessage = ExceptionExtensions.ToTypeMessageString(ex);
			return new ErrorDescriptor(ErrorSeverity.Warning, newErrDescMessage);
		}

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			var descriptors = ErrorDescriptors.Create();

			if (value is IEnumerable<object> rawObj)
			{
				foreach (var error in rawObj.OfType<ErrorDescriptor>())
				{
					descriptors.Add(error);
				}

				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)
			{
				return null;
			}

			var highPrioError = descriptors.OrderByDescending(p => p.Severity).FirstOrDefault();

			if (ErrorSeverityColorConverter.ErrorSeverityColors.TryGetValue(highPrioError.Severity, out var brush))
			{
				return brush;
			}
			else
			{
				return null;
			}
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}

{'fraction_non_alphanumeric': 0.0840240068591026, 'fraction_numerical': 0.0, 'mean_word_length': 4.2395209580838324, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2277082', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1055, 'n_words': 225}