Menu

#1 Catching deleted message exceptions

open
nobody
None
5
2004-02-27
2004-02-27
No

When the news server has deleted a message GetArticle
will raise an NoSuchArticleException. I'm not sure this
is a bug in the news servers I've tested this with
(msnews.microsoft.com as well as my own IIS6 NNTP
server) or whether it is incorrect to include the id
for the deleted message in the list of messages in the
group.

This patch just uses try catch so that GetArticles does
not fail due to deleted messages.

When could GetArticle return null? I removed that test
because it did not seem realistic.

--- NewsGroup.cs 27 Feb 2003 21:38:45 -0000 1.12
+++ NewsGroup.cs 27 Feb 2004 11:54:56 -0000
@@ -240,9 +240,18 @@
NNTPStatusResponse response =
Utils.ParseResponse(articles[0]);
if (response.StatusCode ==
NNTPStatus.ListOfNewArticles)
{
+ Article article;
for (int i = 1; i <= articles.Length - 3; i++)
{
- Article article = this.GetArticle(headersOnly,
articles[i], false);
+ try
+ {
+ article = this.GetArticle(headersOnly,
articles[i], false);
+ }
+ catch ( NoSuchArticleException ex )
+ {
+ // if the article has been removed from the server
+ continue;
+ }
results.Add(article.Header.MessageID, article);
}
}
@@ -329,11 +338,19 @@
{
count = articleNumbers.Length - startIndex;
}
+ Article article;
for (int i = startIndex; i < startIndex + count; i++)
{
- Article article = this.GetArticle(headersOnly,
articleNumbers[i], false);
- if (article != null)
+ try
+ {
+ article = this.GetArticle(headersOnly,
articleNumbers[i], false);
results.Add(article.Header.MessageID, article);
+ }
+ catch ( NoSuchArticleException ex )
+ {
+ // if article has been removed from server
+ continue;
+ }
}
}
this.session.Disconnect();

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.