throw more detailed exceptions for type not found and interface mismatches

This commit is contained in:
Brendan Forster
2014-02-20 22:11:02 +11:00
parent 14de4a6edf
commit 87638fc41d
6 changed files with 96 additions and 11 deletions
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace Octokit.Tests.Conventions
{
public class InterfaceHasAdditionalMethodsException : Exception
{
public InterfaceHasAdditionalMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient)
: base(CreateMessage(type, methodsMissingOnReactiveClient)) { }
public InterfaceHasAdditionalMethodsException(Type type, IEnumerable<string> methodsMissingOnReactiveClient, Exception innerException)
: base(CreateMessage(type, methodsMissingOnReactiveClient), innerException) { }
protected InterfaceHasAdditionalMethodsException(SerializationInfo info, StreamingContext context)
: base(info, context) { }
static string CreateMessage(Type type, IEnumerable<string> methods)
{
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
return String.Format("Methods found on type {0} which should be removed:\r\n{1}", type.Name, methodsFormatted);
}
}
}