Make article extractor report correct state on failed Mercury parses

This commit is contained in:
Maurice Parker 2019-10-04 07:39:49 -05:00
parent 269b9315b2
commit f7fd003f3c

View File

@ -79,11 +79,12 @@ class ArticleExtractor {
decoder.dateDecodingStrategy = .iso8601 decoder.dateDecodingStrategy = .iso8601
self.article = try decoder.decode(ExtractedArticle.self, from: data) self.article = try decoder.decode(ExtractedArticle.self, from: data)
self.state = .complete
DispatchQueue.main.async { DispatchQueue.main.async {
if self.article?.content == nil { if self.article?.content == nil {
self.state = .failedToParse
self.delegate?.articleExtractionDidFail(with: URLError(.cannotDecodeContentData)) self.delegate?.articleExtractionDidFail(with: URLError(.cannotDecodeContentData))
} else { } else {
self.state = .complete
self.delegate?.articleExtractionDidComplete(extractedArticle: self.article!) self.delegate?.articleExtractionDidComplete(extractedArticle: self.article!)
} }
} }