<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace AppHarbor
{
	public class TypeNameMatcher<T>
	{
		private readonly IEnumerable<Type> _candidateTypes;

		public TypeNameMatcher(IEnumerable<Type> candidateTypes)
		{
			if (candidateTypes.Any(x => !typeof(T).IsAssignableFrom(x)))
			{
				throw new ArgumentException(string.Format("{0} must be assignable from all injected types", typeof(T).FullName), "candidateTypes");
			}
			_candidateTypes = candidateTypes;
		}

		public Type GetMatchedType(string commandName, string scope)
		{
			var scopedTypes = _candidateTypes.Where(x => x.Name.EndsWith(string.Concat(scope, "Command")));

			try
			{
				return scopedTypes.Single(x => x.Name.ToLower().StartsWith(commandName.ToLower()));
			}
			catch (InvalidOperationException)
			{
				throw new ArgumentException("No candidate type matches", "commandName");
			}
		}
	}
}<commit_msg>Change exception message and pass innerexception to argumentexception<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace AppHarbor
{
	public class TypeNameMatcher<T>
	{
		private readonly IEnumerable<Type> _candidateTypes;

		public TypeNameMatcher(IEnumerable<Type> candidateTypes)
		{
			if (candidateTypes.Any(x => !typeof(T).IsAssignableFrom(x)))
			{
				throw new ArgumentException(string.Format("{0} must be assignable from all injected types", typeof(T).FullName), "candidateTypes");
			}
			_candidateTypes = candidateTypes;
		}

		public Type GetMatchedType(string commandName, string scope)
		{
			var scopedTypes = _candidateTypes.Where(x => x.Name.EndsWith(string.Concat(scope, "Command")));

			try
			{
				return scopedTypes.Single(x => x.Name.ToLower().StartsWith(commandName.ToLower()));
			}
			catch (InvalidOperationException exception)
			{
				throw new ArgumentException("Error while matching type", "commandName", exception);
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.11536471805483704, 'fraction_numerical': 0.0010346611484738748, 'mean_word_length': 4.896341463414634, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '5194905', 'n_tokens_mistral': 665, 'n_tokens_neox': 587, 'n_words': 127}