@@ -97,7 +97,12 @@ extension ProtoDate: Decodable {
9797 if let year = try container. decodeIfPresent ( Int . self, forKey: . year) , year != 0 {
9898 guard year >= 1 && year <= 9999 else {
9999 throw DecodingError . dataCorrupted (
100- . init( codingPath: [ CodingKeys . year] , debugDescription: " Invalid year: \( year) " )
100+ DecodingError . Context (
101+ codingPath: [ CodingKeys . year] ,
102+ debugDescription: """
103+ Invalid year: \( year) ; must be from 1 to 9999, or 0 for a date without a specified year.
104+ """
105+ )
101106 )
102107 }
103108 self . year = year
@@ -108,7 +113,13 @@ extension ProtoDate: Decodable {
108113 if let month = try container. decodeIfPresent ( Int . self, forKey: . month) , month != 0 {
109114 guard month >= 1 && month <= 12 else {
110115 throw DecodingError . dataCorrupted (
111- . init( codingPath: [ CodingKeys . month] , debugDescription: " Invalid month: \( month) " )
116+ DecodingError . Context (
117+ codingPath: [ CodingKeys . month] ,
118+ debugDescription: """
119+ Invalid month: \( month) ; must be from 1 to 12, or 0 for a year date without a \
120+ specified month and day.
121+ """
122+ )
112123 )
113124 }
114125 self . month = month
@@ -119,7 +130,12 @@ extension ProtoDate: Decodable {
119130 if let day = try container. decodeIfPresent ( Int . self, forKey: . day) , day != 0 {
120131 guard day >= 1 && day <= 31 else {
121132 throw DecodingError . dataCorrupted (
122- . init( codingPath: [ CodingKeys . day] , debugDescription: " Invalid day: \( day) " )
133+ DecodingError . Context (
134+ codingPath: [ CodingKeys . day] ,
135+ debugDescription: """
136+ Invalid day: \( day) ; must be from 1 to 31, or 0 for a date without a specified day.
137+ """
138+ )
123139 )
124140 }
125141 self . day = day
0 commit comments