Hi!
I have a question regarding Consumers & Exception handling in consumers.
Consider this working example:
public class Foo : IFoo
{}
public class FooConsumer : IConsumer<IFoo>
{
public Task Consume(ConsumeContext<IFoo> context)
{
throw new Exception($"Exception from {this}");
}
}
public class FooConsumerFault : IConsumer<Fault<IFoo>>
{
public Task Consume(ConsumeContext<Fault<IFoo>> context)
{
var faults = context.Message.Exceptions;
Console.WriteLine(faults);
return Task.CompletedTask;
}
}
In our case, we will end up with alot of different consumers and our aim is to have just one FaultConsumer, something like this:
public interface IBase {}
public interface IFoo : IBase
{}
public class Foo : IFoo
{}
public class FooConsumer : IConsumer<IFoo>
{
public Task Consume(ConsumeContext<IFoo> context)
{
throw new Exception($"Exception from {this}");
}
}
public class BaseConsumerFault : IConsumer<Fault<IBase>>
{
public Task Consume(ConsumeContext<Fault<IBase>> context)
{
var faults = context.Message.Exceptions;
Console.WriteLine(faults);
return Task.CompletedTask;
}
}
Is this possible to achieve?
Thanks!