Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created September 7, 2019 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/4f34133107c4bed3daf390f5510c5c4f to your computer and use it in GitHub Desktop.
Save IntegerMan/4f34133107c4bed3daf390f5510c5c4f to your computer and use it in GitHub Desktop.
public class ThrowIfMismatchedPublisher : IResultPublisher
{
public Task Publish<T, TClean>(Result<T, TClean> result)
{
if (result.Mismatched)
{
var sb = new StringBuilder();
sb.AppendLine($"{result.ExperimentName} had mismatched results: ");
foreach (var observation in result.MismatchedObservations)
{
sb.AppendLine($"Value: {observation.Value}");
}
throw new InvalidOperationException(sb.ToString());
}
return Task.CompletedTask;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment