I have implemented IErrorHandler in my WCF service to determine what should be sent to a client (ProvideFault) and for logging the exception (HandleError).
As part of this process I want to:
- Send the client an error code with some standard text to hide the internal exception details.
- Log the error with the same error code so that I can match up the entry in the log file with the error report from the client.
I have been looking into this and cannot find a way where the same error code will be guaranteed to be used in both methods as HandleError will be called at some time in the future on a separate thread. This would seem to rule out having some kind of class level counter as ProvideFault could be called twice before HandleError is called.
Has anyone come up against the same situation and worked out a solution/pattern to use in this scenario?