I have a webservice that, if appropriate, sends out error messages.
I would like those error messages to be pretty limited (“Internal crash”) in production mode, and pretty thorough in debug mode.
I thought about using [Conditional("DEBUG")], but it only works with methods returning void.
Do I really have to use #ifdef around my error messaging, or black arcane magicking (like using said conditional method to tell the webservice object to get into a “debug mode”, which seems rather ugly to me, as it’s imho not something the object should be aware of at all)?
Is there a trick or appropriate method I’m unaware of?
You can setup a behavior in WCF that catches all exceptions and then removes most of the error information if you are in the production mode. You can setup the mode with a flag in the web.config file.