Allow Handle to use function call without Exception generic type
Hi,
Handle expects an exception each time. This makes it difficult to have standard policy handlers using a decorator pattern across the system. This is because the exception to trap may be different based on the context, i.e. In one part of the system the exception may be System.TimeoutException, in another it may be a SqlException, but the Policy handling is the same.
Either allow injection of the Handle logic via DI with an interface, or allow Handle to take a function method that just returns a bool, thereby allowing in-line anonymous methods to do a similar job to DI
Thanks!
You can have a policy handle System.Exception, all exceptions inherit from that.
Tom is correct. You can do this:
Policy.Handle<Exception>(ex => /* Generic logic here */)