Skip to content

Commit d93e0df

Browse files
authored
Merge pull request #15636 from Fidetro/master
Fixed JSONEncoder code style issues
2 parents 916e162 + 2bf6b88 commit d93e0df

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

stdlib/public/SDK/Foundation/JSONEncoder.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,22 +212,27 @@ open class JSONEncoder {
212212
let encoder = _JSONEncoder(options: self.options)
213213

214214
guard let topLevel = try encoder.box_(value) else {
215-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) did not encode any values."))
215+
throw EncodingError.invalidValue(value,
216+
EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) did not encode any values."))
216217
}
217218

218219
if topLevel is NSNull {
219-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as null JSON fragment."))
220+
throw EncodingError.invalidValue(value,
221+
EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as null JSON fragment."))
220222
} else if topLevel is NSNumber {
221-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as number JSON fragment."))
223+
throw EncodingError.invalidValue(value,
224+
EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as number JSON fragment."))
222225
} else if topLevel is NSString {
223-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as string JSON fragment."))
226+
throw EncodingError.invalidValue(value,
227+
EncodingError.Context(codingPath: [], debugDescription: "Top-level \(T.self) encoded as string JSON fragment."))
224228
}
225229

226230
let writingOptions = JSONSerialization.WritingOptions(rawValue: self.outputFormatting.rawValue)
227231
do {
228232
return try JSONSerialization.data(withJSONObject: topLevel, options: writingOptions)
229233
} catch {
230-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value to JSON.", underlyingError: error))
234+
throw EncodingError.invalidValue(value,
235+
EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value to JSON.", underlyingError: error))
231236
}
232237
}
233238
}

stdlib/public/SDK/Foundation/PlistEncoder.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ open class PropertyListEncoder {
6868
do {
6969
return try PropertyListSerialization.data(fromPropertyList: topLevel, format: self.outputFormat, options: 0)
7070
} catch {
71-
throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value as a property list", underlyingError: error))
71+
throw EncodingError.invalidValue(value,
72+
EncodingError.Context(codingPath: [], debugDescription: "Unable to encode the given top-level value as a property list", underlyingError: error))
7273
}
7374
}
7475

0 commit comments

Comments
 (0)