From 4401503b85dff83bad61e43e5515dad54869445e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 23 Apr 2023 14:38:00 -0400 Subject: [PATCH] More detailed error when status URL decoding fails See #373 --- Packages/Pachyderm/Sources/Pachyderm/Model/Status.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Packages/Pachyderm/Sources/Pachyderm/Model/Status.swift b/Packages/Pachyderm/Sources/Pachyderm/Model/Status.swift index 133a5d47..a5ff6f37 100644 --- a/Packages/Pachyderm/Sources/Pachyderm/Model/Status.swift +++ b/Packages/Pachyderm/Sources/Pachyderm/Model/Status.swift @@ -48,7 +48,12 @@ public final class Status: StatusProtocol, Decodable, Sendable { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(String.self, forKey: .id) self.uri = try container.decode(String.self, forKey: .uri) - self.url = try container.decodeIfPresent(WebURL.self, forKey: .url) + do { + self.url = try container.decodeIfPresent(WebURL.self, forKey: .url) + } catch { + let s = (try? container.decode(String.self, forKey: .url)) ?? "" + throw DecodingError.dataCorruptedError(forKey: .url, in: container, debugDescription: "Could not decode URL '\(s)', reason: \(String(describing: error))") + } self.account = try container.decode(Account.self, forKey: .account) self.inReplyToID = try container.decodeIfPresent(String.self, forKey: .inReplyToID) self.inReplyToAccountID = try container.decodeIfPresent(String.self, forKey: .inReplyToAccountID)