I have a small section of code invoking a webservice client method.
The method returns an array of messages as an out parameter. Often these messages contain details of any errors that have occured. When an error does occur an exception is also thrown.
I want to log the messages regardless of whether an exception is thrown or the type of the exception. Is logging in the finally block acceptable practice?
WebServiceClient client = GetWebServiceClient();
Console.WriteLine("Calling getUpdates...");
ItemStatus[] itemStatuses;
Message[] messages = null;
string outToken;
try
{
outToken = client.getUpdates(inToken, out itemStatuses, out messages);
}
finally
{
LogMessages(messages);
}