I am using the C# Productivity Layer to work with DFS. Suppose an exception arises during a DFS call. I want my application to display a useful error message, produced from the caught exception.
The problem is: text I see in Exception.Message is not always useful. For instance, if specified server cannot be found, Exception.Message has value @“Service method "Execute" invocation failed.”. And only (Exception.InnerException).Message contains useful description of the problem: @“ There was no endpoint listening at http://wswerer/core/QueryService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.”
In its turn, ((Exception.InnerException).InnerException).Message contains @” The remote name could not be resolved: 'wswerer'”. This one seems to be most appropriate to be displayed as error message.
So, should I use the following algorithm to get a ‘most appropriate’ error message: go deep into InnerException hierarchy until it becomes null, and use Message of the ‘most inner’ Exception object? Will this rule work?