This project has moved. For the latest updates, please go here.

how to catch exception

Apr 2, 2008 at 8:58 PM
I have RssToolkit to do the RssFeed. I could catch exception if the feed is not exist RssToolkit throw exception. then I could handle the errors.

But, I had one feed http://xml.weather.yahoo.com/forecastrss?p=USPA0081&u=f
it won't throw exception and give back the xml files. But I think the date is not match my system.
So it always give me error:
he string was not recognized as a valid DateTime. There is a unknown word starting at index 25.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 25.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

FormatException: The string was not recognized as a valid DateTime. There is a unknown word starting at index 25.
System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) +2291962
System.DateTime.Parse(String s, IFormatProvider provider) +26
RssToolkit.Rss.RssXmlHelper.Parse(String dateTime) +1455
RssToolkit.Rss.RssItem.get_PubDateParsed() +36
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterRssDocument.Write8_RssItem(String n, String ns, RssItem o, Boolean isNullable, Boolean needType) +815
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterRssDocument.Write13_RssChannel(String n, String ns, RssChannel o, Boolean isNullable, Boolean needType) +923
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterRssDocument.Write14_RssDocument(String n, String ns, RssDocument o, Boolean isNullable, Boolean needType) +302
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterRssDocument.Write15_rss(Object o) +125

InvalidOperationException: There was an error generating the XML document.
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) +647
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle) +43
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces) +39
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces) +93
System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o) +35
RssToolkit.Rss.RssXmlHelper.ToRssXml(T rssDocument) +249
RssToolkit.Rss.RssDocumentBase.ToXml(DocumentType outputType, T rssDocument) +75
RssToolkit.Rss.RssDocument.ToXml(DocumentType outputType) +35
RssToolkit.Rss.RssDocument.ToDataSet() +29
RssToolkit.Rss.RssDocument.SelectItems(Int32 maxItems, Boolean reverseOrder) +51
RssToolkit.Rss.RssDocument.SelectItems(Int32 maxItems) +32
RssToolkit.Web.Design.RssDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +59
System.Web.UI.WebControls.BaseDataList.GetData() +54
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +381
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +75
System.Web.UI.WebControls.BaseDataList.DataBind() +85
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +82
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +91
System.Web.UI.Control.EnsureChildControls() +133
System.Web.UI.Control.PreRenderRecursiveInternal() +109
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Control.PreRenderRecursiveInternal() +233
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +4421



I try to use try catch block. But it didn't go into catch block.

Anybody knows how do I catch exception and handle it ???
Appreciate