I have two sets of code which are literally same but only one code set works and another doesn't

import Foundation



enum VideoDetails: String, CaseIterable{

    case Nature , Food , Animals , Travel

}



struct ResponseBody: Decodable {

    var page: Int

    var perPage: Int

    var totalResults: Int

    var url: String

    var videos: [Video]

    

}

    

struct Video: Identifiable, Decodable{

    var id: Int

    var image: String

    var duration: Int

    var user: User

    var videofiles: [VideoFile]

        

    

    

    struct User: Identifiable, Decodable {

      var id: Int

      var name: String

      var url: String

   }

           

    struct VideoFile: Identifiable, Decodable {

      var id: Int

      var quality: String

      var fileType: String

      var link: String

   }

 }

  //this one doesn't work but the below code works perfectly can anyone why it is happening

import Foundation

enum VideoDetails: String, CaseIterable{

    case Nature , Food , Animals , Travel

}

struct Video: Identifiable, Decodable {

    var id: Int

    var image: String

    var duration: Int

    var user: User

    var videoFiles: [VideoFile]

    

    struct User: Identifiable, Decodable {

        var id: Int

        var name: String

        var url: String

    }

    

    struct VideoFile: Identifiable, Decodable {

        var id: Int

        var quality: String

        var fileType: String

        var link: String

    }

}

Doesn't work does not bring useful information.

Does it crash ? Not compile ? Does it give unexpected results ?

What do you get exactly ? What did you expect ? Where exactly is the error ?

I note that ResponseBody is unused. Is it on purpose ?

Doesn’t work means it throws error on Json decoder in catch statement it throws this error only for the first code not for the second cide below the comment although those two code looks similar to me do you find any differences in these two codes (above and below the comment)

Please show the code where the catch statement triggers.

what you provises is not enough as the extra code in part 1 is not uses anywhere.

I have two sets of code which are literally same but only one code set works and another doesn't
 
 
Q