I am new to WCF. I have multiple methods throwing the same exceptions for the same calls/validation. In-order to reduce the amount of code in the class, I can create validation helper methods to validate and throw exceptions. But at the same time, if I want to log the exceptions somewhere, I can’t use the stacktrace/line of code.
I am using Microsoft Enterprise Logger for this service, It can help me trace back to the method that called this validation. But I am also thinking of using WCF diagnostics logger that can help me log the exceptions, it might be harder for me to trace back to the method that called a specific helper method.
whats the best way to do this? Reduce the amount of code by creating validation methods, that throw exceptions, or just validate and throw exceptions in the original methods.
Using a helper function should not be a concern. You get the call stack with the exception so you can see where your helper function was called from.