I was testing with the Headlines app that I had completed from the starter version, but the completed app still crash and other issues with some of the news sources.
So I went and tested the final version of Headlines app that came with the downloaded source code, and the same problem occurred with raywenderlich’s final version as well. Here are the news sources that either crash the app or did not crash but with issues indicated in the console output.
Most are valueNotFound errors, one with dataCorrupted.
The decoding errors are associated with this statement:
if let articles = try! decoder.decode(Response.self, from: data).articles {
self.articles = articles
}
Is there any way to correct the app to make it run correctly?
Al Jazeera English:
Thread 4: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 4”, intValue: 4), CodingKeys(stringValue: “description”, intValue: nil)], debugDescription: “Expected String value but found null instead.”, underlyingError: nil))
Bloomberg:
Thread 8: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 1”, intValue: 1), CodingKeys(stringValue: “description”, intValue: nil)], debugDescription: “Expected String value but found null instead.”, underlyingError: nil))
Financial Times:
Thread 2: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 4”, intValue: 4), CodingKeys(stringValue: “description”, intValue: nil)], debugDescription: “Expected String value but found null instead.”, underlyingError: nil))
Football Italia:
Thread 4: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 2”, intValue: 2), CodingKeys(stringValue: “urlToImage”, intValue: nil)], debugDescription: “Invalid URL string.”, underlyingError: nil))
Fortune: Did not crash, but with this console output - 2018-07-07 12:06:52.375811-0700 Headlines[24691:1512052] Task .<8> finished with error - code: -1002
Fox Sports:
Thread 20: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 2”, intValue: 2), CodingKeys(stringValue: “description”, intValue: nil)], debugDescription: “Expected String value but found null instead.”, underlyingError: nil))
Hacket News:
Thread 3: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Swift.String, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 0”, intValue: 0), CodingKeys(stringValue: “description”, intValue: nil)], debugDescription: “Expected String value but found null instead.”, underlyingError: nil))
Independent:
Thread 10: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Foundation.URL, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 7”, intValue: 7), CodingKeys(stringValue: “urlToImage”, intValue: nil)], debugDescription: “Expected URL value but found null instead.”, underlyingError: nil))
National Geographic: Did not crash, but with console outputs -
2018-07-07 12:13:47.079312-0700 Headlines[24788:1518027] init:1303: *** ImageIO AppleJPEG decode failed - falling back to libJEG
Newsweek:
Thread 13: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Foundation.URL, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 5”, intValue: 5), CodingKeys(stringValue: “urlToImage”, intValue: nil)], debugDescription: “Expected URL value but found null instead.”, underlyingError: nil))
The Telegraph: Did not crash, but with console outputs -
2018-07-07 12:17:36.204447-0700 Headlines[24817:1524051] TIC Read Status [39:0x604000178000]: 1:57
Time: Did not crash, but with console outputs -
2018-07-07 12:19:54.862639-0700 Headlines[24817:1525822] TIC Read Status [62:0x0]: 1:57
USA Today: Did not crash, but with console output -
2018-07-07 12:25:37.190947-0700 Headlines[24817:1529885] Task <0EE0976F-8A67-412C-B947-9122BD09C740>.<294> finished with error - code: -999
Wirtschafts Woche:
Thread 79: Fatal error: ‘try!’ expression unexpectedly raised an error: Swift.DecodingError.valueNotFound(Foundation.URL, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: “articles”, intValue: nil), _JSONKey(stringValue: “Index 1”, intValue: 1), CodingKeys(stringValue: “urlToImage”, intValue: nil)], debugDescription: “Expected URL value but found null instead.”, underlyingError: nil))