Report string when mention url decoding fails

This commit is contained in:
Shadowfacts 2023-09-09 11:41:54 -04:00
parent 9c3be68e1c
commit b28792eb29
1 changed files with 6 additions and 1 deletions

View File

@ -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 ?? "<failed to decode string>")'")
}
}
public init(url: WebURL, username: String, acct: String, id: String) {