Getting more details on decoding errors

Hello!
Is there any way to get more details on decoding errors?
Codable provides some nice logging with the try catch mechanism. is there any way to use that?

I’m currently having issues with a request. I am trying to get a list of objects. and for some reason, it fails to decode one object, therefore it fails the entire request. And the object is pretty complex too, so I don’t have an idea really how to pinpoint the incorrect format or whatever else is wrong. I just get
The data couldn’t be read because it isn’t in the correct format
I can share the actual response if needed (although it’s quite big)

For more details, this is the mock object:

The unit test:

func testUserEventWithErrorsGetsDecoded() throws {
        let data = try getData(name: "UserEventWithErrors")
        XCTAssertNoThrow(try ParseCoding.jsonDecoder().decode(UserEvent.self, from: data))
    }
    
    func getData(name: String, withExtension: String = "json") throws -> Data {
        let bundle = Bundle(for: type(of: self))
        let fileUrl = bundle.url(forResource: name, withExtension: withExtension)
        let data = try Data(contentsOf: fileUrl!)
        return data
    }

The object:

import ParseSwift

enum UserEventStatus: String, Codable {
    case submitted, draft, incomplete, reviewing, active, closed, archived
}

/*
 reviewing = incomplete, submitted
 */

struct UserEvent: ParseObject {
    static func == (lhs: UserEvent, rhs: UserEvent) -> Bool {
        lhs.hasSameObjectId(as: rhs)
    }

    func hash(into hasher: inout Hasher) {
        hasher.combine(objectId)
        hasher.combine(title)
        hasher.combine(description)
    }
    
    init() {
        
    }
    
    var originalData: Data?
    
    var objectId: String?
    
    var createdAt: Date?
    
    var updatedAt: Date?
    
    var ACL: ParseACL?
    
    
    var title: String?
    var description: String?
    var hashtags: [String]?
    var templateImage: String?
    var inspirationImage: String?
    var requirements: UserEventRequirements?
    var status: UserEventStatus?
    
    var user: User?
    var errors: UserEventErrors?
}

struct UserEventErrors: Codable {
    let title: [UserEventError]?
    var description: [UserEventError]?
    let hashtags: [UserEventError]?
    let collectionThumb: [UserEventError]?
    let collectionTemplate: [UserEventError]?
}

struct UserEventError: Codable {
    let problem: String?
    let comment: String?
    let replace: String?
    let with: String?
}

The test runs correctly. but in the project itself I get that error. which is incredibly strange.
This is the full error:

    "Access-Control-Allow-Headers" =     (
        "X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, X-Parse-Request-Id, Content-Type, Pragma, Cache-Control"
    );
    "Access-Control-Allow-Methods" =     (
        "GET,PUT,POST,DELETE,OPTIONS"
    );
    "Access-Control-Allow-Origin" =     (
        "*"
    );
    "Access-Control-Expose-Headers" =     (
        "X-Parse-Job-Status-Id, X-Parse-Push-Status-Id"
    );
    Connection =     (
        "keep-alive"
    );
    "Content-Length" =     (
        11827
    );
    "Content-Type" =     (
        "application/json; charset=utf-8"
    );
    Date =     (
        "Tue, 12 Jul 2022 09:03:27 GMT"
    );
    Etag =     (
        "W/\"2e33-lpiBYleSleuJcWFc/qKteQ34Oew\""
    );
    Server =     (
        Cowboy
    );
    "Strict-Transport-Security" =     (
        "max-age=15552000; includeSubDomains"
    );
    Via =     (
        "1.1 vegur"
    );
    "X-Content-Type-Options" =     (
        nosniff
    );
    "X-Dns-Prefetch-Control" =     (
        off
    );
    "X-Download-Options" =     (
        noopen
    );
    "X-Frame-Options" =     (
        SAMEORIGIN
    );
    "X-Powered-By" =     (
        Express
    );
    "X-Xss-Protection" =     (
        "1; mode=block"
    );
} } with error: The data couldn’t be read because it isn’t in the correct format. Format: Optional("{\"result\":{\"userEvents\":[{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/0fed2f82-e48c-4429-8fc9-0409d558e07e-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/55f86dec-231c-4ff2-aaf9-02a8075248c4-300w.jpeg\",\"createdAt\":\"2022-07-11T15:56:16.630Z\",\"updatedAt\":\"2022-07-11T16:01:28.521Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"Khwf9NMPQf\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"draft\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/bd3d361a-7a8d-432e-8c0b-4161e871a4e4-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/2290d170-34ed-45cc-800a-792c25a76855-300w.jpeg\",\"createdAt\":\"2022-07-11T15:31:11.536Z\",\"updatedAt\":\"2022-07-11T15:31:11.536Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"D8ObHijuH6\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"draft\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/1c8e0b04-93a1-4ad9-ae19-d00f533391b8-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/beb07e33-e8aa-4d6a-a2a4-8ed9a67820c9-300w.jpeg\",\"createdAt\":\"2022-07-11T15:30:26.401Z\",\"updatedAt\":\"2022-07-11T15:30:26.401Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"OoUt0CsUXQ\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/efd0636b-b194-4f49-af33-b246c13c54d2-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/eb80b3a8-4e26-4082-8952-5b5abd986aa2-300w.jpeg\",\"createdAt\":\"2022-07-11T15:27:56.657Z\",\"updatedAt\":\"2022-07-11T16:06:09.862Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"tjwz3bHgsS\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/cadd7d94-22c6-4adb-8f86-2a618506d692-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/62b1cb00-4374-4328-96f1-1b36c670f72c-300w.jpeg\",\"createdAt\":\"2022-07-11T15:26:52.714Z\",\"updatedAt\":\"2022-07-11T16:01:40.942Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"zwgjaBbLBE\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/b727a9ef-c987-4559-b1c6-b5cf169eb457-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/61b6cc4d-3f2a-458f-9bea-1634ee14e63a-300w.jpeg\",\"createdAt\":\"2022-07-11T15:25:15.475Z\",\"updatedAt\":\"2022-07-11T16:07:25.432Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"NcHIgYdF2L\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"draft\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/78810125-6276-404a-b100-b4c5b0e82874-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/f4036013-3fcc-47e3-9211-1957fee61f9f-300w.jpeg\",\"createdAt\":\"2022-07-11T15:24:29.796Z\",\"updatedAt\":\"2022-07-11T15:24:29.796Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"f265AwmVor\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/d497dad9-050d-4c2e-afbf-d776d8116c7f-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/f5e51e5e-1476-4338-bfd4-c2a06498ceef-300w.jpeg\",\"createdAt\":\"2022-07-07T18:22:57.556Z\",\"updatedAt\":\"2022-07-07T18:23:42.891Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"sTRFQBODAV\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/77b60c99-924c-4c63-95ae-ed2a8d4e1d6e-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/23de4828-c7fc-44d4-8b56-843e0a103544-300w.jpeg\",\"createdAt\":\"2022-07-07T18:21:02.614Z\",\"updatedAt\":\"2022-07-11T16:03:43.892Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"KhWvGtlHyJ\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/e209bea1-0c95-4596-a215-ecdc3d56e48c-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/9f89e372-6af4-4a4f-a4c5-22392814826e-300w.jpeg\",\"createdAt\":\"2022-07-07T18:20:03.463Z\",\"updatedAt\":\"2022-07-11T14:47:34.377Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"d8YfoIem5V\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"My very unique title\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/cf6d6c44-7d31-4ad5-8cdd-80340207accd-300w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/userEvents/FnDrCk35yF/24458cec-82a6-4968-88e5-0bd94989019d-300w.jpeg\",\"createdAt\":\"2022-07-07T18:15:35.908Z\",\"updatedAt\":\"2022-07-11T16:02:13.710Z\",\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"NWxbZvHZuS\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"incomplete\",\"title\":\"My title 2\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d-750w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9-750w.jpeg\",\"createdAt\":\"2022-06-21T15:34:12.603Z\",\"updatedAt\":\"2022-06-28T17:26:12.835Z\",\"collectionTemplate\":{\"exe\":0.337,\"cdn\":\"https://cdn.decormatters.com/\",\"key\":\"events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9\",\"ext\":{\"jpeg\":\"image/jpeg\"},\"default\":\"https://cdn.decormatters.com/events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9-750w.jpeg\",\"set\":[{\"size\":750,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9-750w.jpeg\"},{\"size\":1500,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9-1500w.jpeg\"},{\"size\":240,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/7c111458-3270-42f2-817a-36526409ade9-240w.jpeg\"}]},\"collectionThumb\":{\"exe\":0.805,\"cdn\":\"https://cdn.decormatters.com/\",\"key\":\"events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d\",\"ext\":{\"jpeg\":\"image/jpeg\"},\"default\":\"https://cdn.decormatters.com/events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d-750w.jpeg\",\"set\":[{\"size\":750,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d-750w.jpeg\"},{\"size\":1500,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d-1500w.jpeg\"},{\"size\":240,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/70757c39-68a9-4da4-8c16-66507364426d-240w.jpeg\"}]},\"expiresAt\":{\"__type\":\"Date\",\"iso\":\"2022-07-09T17:40:06.707Z\"},\"featuredAt\":{\"__type\":\"Date\",\"iso\":\"2022-06-24T17:40:06.707Z\"},\"errors\":{\"title\":[{\"problem\":\"fix_bad_word\",\"comment\":\"Please change the word title\"}],\"description\":[{\"problem\":\"fix_other\",\"comment\":\"not enough description\"}],\"hashtags\":[{\"problem\":\"fix_replace\",\"replace\":\"\",\"with\":\"\"}],\"collectionThumb\":[{\"problem\":\"fix_low_resolution\",\"comment\":\"Looks too blurry\"}],\"collectionTemplate\":[{\"problem\":\"fix_adult\"}]},\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"SjS9YSBMdH\",\"__type\":\"Object\",\"className\":\"UserEvent\"},{\"hashtags\":[],\"requirements\":{\"color\":[\"Yellow\"],\"roomType\":[{\"id\":\"30000\",\"name\":\"Living Room\"}]},\"user\":{\"__type\":\"Pointer\",\"className\":\"_User\",\"objectId\":\"FnDrCk35yF\"},\"status\":\"archived\",\"title\":\"Test errors\",\"description\":\"some description\",\"inspirationImage\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd-750w.jpeg\",\"templateImage\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e-750w.jpeg\",\"createdAt\":\"2022-06-20T11:28:57.107Z\",\"updatedAt\":\"2022-07-07T18:14:16.489Z\",\"errors\":{\"description\":{\"general\":\"fix language\",\"suggestions\":[{\"startLocation\":15,\"endLocation\":25,\"suggestion\":\"living room\"}]}},\"collectionTemplate\":{\"exe\":0.467,\"cdn\":\"https://cdn.decormatters.com/\",\"key\":\"events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e\",\"ext\":{\"jpeg\":\"image/jpeg\"},\"default\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e-750w.jpeg\",\"set\":[{\"size\":750,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e-750w.jpeg\"},{\"size\":1500,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e-1500w.jpeg\"},{\"size\":240,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98dc049a-5568-4049-94ae-83d9bb64f92e-240w.jpeg\"}]},\"collectionThumb\":{\"exe\":0.816,\"cdn\":\"https://cdn.decormatters.com/\",\"key\":\"events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd\",\"ext\":{\"jpeg\":\"image/jpeg\"},\"default\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd-750w.jpeg\",\"set\":[{\"size\":750,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd-750w.jpeg\"},{\"size\":1500,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd-1500w.jpeg\"},{\"size\":240,\"url\":\"https://cdn.decormatters.com/events/dJyh50WLEw/98e3dfa6-9c3a-408e-8b62-1b1687317fdd-240w.jpeg\"}]},\"expiresAt\":{\"__type\":\"Date\",\"iso\":\"2022-07-09T17:56:39.783Z\"},\"featuredAt\":{\"__type\":\"Date\",\"iso\":\"2022-06-25T17:56:39.783Z\"},\"ACL\":{\"*\":{\"read\":true}},\"objectId\":\"tHkrkrZ43L\",\"__type\":\"Object\",\"className\":\"UserEvent\"}]}}")

Your JSON object is quite long, I recommend checking the text after, Format: Optional( and pasting it back here in a more readable format with new lines. There’s something in that JSON that isn’t matching your ParseObject struct.

In addition, you shouldn’t need to add static func == (lhs: UserEvent, rhs: UserEvent) and func hash(into hasher: inout Hasher) if you setup your ParseObject properly. My guess is the problem is with UserEventRequirements, UserEventStatus, and UserEventErrors. All of your objects properties should conform to Codable, Hashable and then you can remove the aforementioned methods from your ParseObject.

To start, I would comment out var errors: UserEventErrors? and see if your ParseObject decodes, if it does, then the problem is in your UserEventErrors struct. Next, I recommend commenting out UserEventStatus and go through the same process.

The SDK uses the standard Swift JSONDecoder, you would probably need to find an open source package that provides more details for decoding errors if you need more details. You can try to add your test to parse-server-swift as the decoder there seems to provide more detailed info about errors:

Hello @cbaker6 and thank you for your suggestions. Applied them. much cleaner. I assumed they’re (the nested objects) automatically conform to Hashable. I forgot I need to manually conform them to the protocol.

I think it’s because description is a reserved keyword in Swift. I added custom decoding and it seems to work now. A bit ugly imo, but it works.

struct UserEventErrors: Codable, Hashable {
    let title: [UserEventError]?
    let description: [UserEventError]?
    let hashtags: [UserEventError]?
    let collectionThumb: [UserEventError]?
    let collectionTemplate: [UserEventError]?
    
    init(from decoder: Decoder) throws {
        let values = try decoder.container(keyedBy: CodingKeys.self)
        title = try? values.decode([UserEventError]?.self, forKey: .title)
        description = try? values.decode([UserEventError]?.self, forKey: .description)
        hashtags = try? values.decode([UserEventError]?.self, forKey: .hashtags)
        collectionThumb = try? values.decode([UserEventError]?.self, forKey: .collectionThumb)
        collectionTemplate = try? values.decode([UserEventError]?.self, forKey: .collectionTemplate)
    }
}
1 Like

You may want to use, description = try values.decodeIfPresent([UserEventError].self, forKey: .description) for keys that may not present during decoding.