Closed neilt closed 5 years ago
The following code fixes the issue for me. Two potential problems with this code.
1) I did not delve into the error handling code to determine if it was appropriate to use the internal error or if it would have been better to define a new error.
2) The case for .atom
appears to potentially have the same problem, but none of my current feeds revealed a problem so I left it alone.
diff --git a/Sources/FeedKit/Parser/XMLFeedParser.swift b/Sources/FeedKit/Parser/XMLFeedParser.swift
index 33b48fc..0597083 100644
--- a/Sources/FeedKit/Parser/XMLFeedParser.swift
+++ b/Sources/FeedKit/Parser/XMLFeedParser.swift
@@ -85,9 +85,15 @@ class XMLFeedParser: NSObject, XMLParserDelegate, FeedParserProtocol {
switch feedType {
case .atom: return Result.atom(self.atomFeed!)
- case .rdf, .rss: return Result.rss(self.rssFeed!)
+ case .rdf, .rss:
+ if let rssFeed = self.rssFeed {
+ return Result.rss(rssFeed)
+ }
+ else {
+ return Result.failure(ParserError.internalError(reason: "No RSS Feed.").value)
+ }
}
-
+
}
/// Redirects characters found between XML elements to their proper model
Hi, @neilt
I was unable to replicate, but safeguarding against a possible uninitializel model seems more than reasonable, so the force unwrap was removed and an appropriate result is now returned.
Thanks
Thanks.
XMLFeedParser line 88.
FeedParser line 117