File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -219,17 +219,28 @@ open class NotificationHandler {
219
219
request.headers.add(name: key, value: value)
220
220
}
221
221
222
- let json = try JSONSerialization.data(withJSONObject: body as Any, options: [])
222
+ if (body != nil) {
223
+ guard let json = try? JSONSerialization.data(withJSONObject: body!, options: []) else {
224
+ return nil
225
+ }
223
226
224
- request.body = .bytes(json)
227
+ request.body = .bytes(json)
228
+ }
225
229
226
- let response = try await client!.http.execute(
230
+ guard let response = try? await client!.http.execute(
227
231
request,
228
232
timeout: .seconds(30)
229
- )
233
+ ) else {
234
+ return nil
235
+ }
230
236
231
- let data = try await response.body.collect(upTo: Int.max)
232
- let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
237
+ guard let data = try? await response.body.collect(upTo: Int.max) else {
238
+ return nil
239
+ }
240
+
241
+ guard let dict = try? JSONSerialization.jsonObject(with: data) as? [String: Any] else {
242
+ return nil
243
+ }
233
244
234
245
return dict
235
246
}
You can’t perform that action at this time.
0 commit comments