File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import Foundation
22
3- public class HolidayJSONLoader {
4- public static func loadHolidays( fromResource resource: String = " holidays_detailed " , bundle: Bundle = . main) -> [ String : Holiday ] {
3+ class HolidayJSONLoader {
4+ static func loadHolidays(
5+ fromResource resource: String = " holidays_detailed " ,
6+ bundle: Bundle = . main
7+ ) -> [ String : Holiday ] {
58 guard let url = bundle. url ( forResource: resource, withExtension: " json " ) else {
6- print ( " [HolidayJSONLoader] JSONファイルが見つかりません: \( resource) .json " )
7- return [ : ]
9+ fatalError ( " [HolidayJSONLoader] Unable to find the JSON file: \( resource) .json " )
810 }
911 guard let data = try ? Data ( contentsOf: url) else {
10- print ( " [HolidayJSONLoader] JSONファイルの読み込みに失敗しました " )
11- return [ : ]
12+ fatalError ( " [HolidayJSONLoader] Failed to load the JSON data: \( url) " )
1213 }
1314 do {
1415 let holidays = try JSONDecoder ( ) . decode ( [ String : Holiday ] . self, from: data)
1516 return holidays
1617 } catch {
17- print ( " [HolidayJSONLoader] JSONのデコードに失敗しました: \( error) " )
18- return [ : ]
18+ fatalError ( " [HolidayJSONLoader] Failed to decode the JSON data: \( error) " )
1919 }
2020 }
2121}
You can’t perform that action at this time.
0 commit comments