09 September 2007

try{} cacth{} ,make it useful!

Microsoft CRM Platform will only throw SoapException whose message property is always "Server was unable to process request.". So we definitely need it in our catch{} try{} .
Plus, if we want to catch SqlException, we need catch it as well. Or to use a common Exception to catch everything!


catch (System.Web.Services.Protocols.SoapException ex)
{
TextWriter log = TextWriter.Synchronized(File.AppendText(@"C:\CRM_Debug\error.txt"));
log.WriteLine("SoapException: " + DateTime.Now.ToString());
log.WriteLine("Error Message: " + ex.Detail.InnerText);
XmlDocument error = new XmlDocument();
error.LoadXml(ex.Detail.InnerXml);
log.WriteLine("Error Code: " + error.SelectSingleNode("/error/code").InnerText);
log.WriteLine("Error Description: " + error.SelectSingleNode("/error/description").InnerText);
log.WriteLine("Error Type: " + error.SelectSingleNode("/error/type").InnerText);
log.WriteLine();
log.Close();
}
catch (SqlException ex)
{
//
}
catch (Exception ex)
{
//
}

1 comment:

Anonymous said...

酒店經紀PRETTY GIRL 台北酒店經紀人 ,禮服店 酒店兼差PRETTY GIRL酒店公關 酒店小姐 彩色爆米花酒店兼職,酒店工作 彩色爆米花酒店經紀, 酒店上班,酒店工作 PRETTY GIRL酒店喝酒酒店上班 彩色爆米花台北酒店酒店小姐 PRETTY GIRL酒店上班酒店打工PRETTY GIRL酒店打工酒店經紀 彩色爆米花