Wcf – In WCF – In the “Faulted” Event – How Do I Get The Exception Details

exceptionwcf

I have a WCF server and I'm tapping into the "Faulted" event which stupidly only gives me "object sender, EventArgs e". How can I get the current 'Exception' object in that event?

Or, if there is some sort of global system way, like Environment.GetCurrentException(), that would be awesome, but I can't find it.

EDIT: To help explain what I'm hoping for… in ASP.NET, you can do "Server.GetLastError()"… Is there such a thing, or anthing even remotely close in WCF? – OperationContext.Current.GetLastError() would be cool 🙂

Best Answer

OK, after some more googling with the right keywords, I've found my answer: http://www.steverb.com/post/Useful-WCF-Behaviors-IErrorHandler