From b28792eb295bdf56842a6feca3eceb7c09d89617 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Sep 2023 11:41:54 -0400 Subject: [PATCH] Report string when mention url decoding fails --- Packages/Pachyderm/Sources/Pachyderm/Model/Mention.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Packages/Pachyderm/Sources/Pachyderm/Model/Mention.swift b/Packages/Pachyderm/Sources/Pachyderm/Model/Mention.swift index 1d353c83..f92d3c46 100644 --- a/Packages/Pachyderm/Sources/Pachyderm/Model/Mention.swift +++ b/Packages/Pachyderm/Sources/Pachyderm/Model/Mention.swift @@ -21,7 +21,12 @@ public struct Mention: Codable, Sendable { self.username = try container.decode(String.self, forKey: .username) self.acct = try container.decode(String.self, forKey: .acct) self.id = try container.decode(String.self, forKey: .id) - self.url = try container.decode(WebURL.self, forKey: .url) + do { + self.url = try container.decode(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 ?? "")'") + } } public init(url: WebURL, username: String, acct: String, id: String) {