using System; using System.Collections.Generic; using System.Linq; namespace InABox.Core { public class DuplicateCodeException : Exception { private readonly Dictionary _duplicates; private readonly Type _type; public DuplicateCodeException(Type type, Dictionary duplicates) { _type = type; _duplicates = duplicates; } public override string Message => string.Format("A {0} with {1} already exists!", _type.Name, string.Join(" and ", _duplicates.Select(x => string.Format("a {0} of ({1})", x.Key, x.Value))) ); } }