Skip to content

Commit 7adb900

Browse files
jameshfisherhamchapman
authored andcommitted
print error on bad response when modifying subscription
1 parent 5665292 commit 7adb900

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

Source/NativePusher.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,18 @@ public class NativePusher {
146146
try! request.HTTPBody = NSJSONSerialization.dataWithJSONObject(params, options: [])
147147
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
148148

149-
let task = URLSession.dataTaskWithRequest(request, completionHandler: { data, response, error in
150-
guard let httpResponse = response as? NSHTTPURLResponse where (httpResponse.statusCode >= 200 && httpResponse.statusCode < 300) else {
151-
// TODO: handle error
152-
return
149+
let task = URLSession.dataTaskWithRequest(
150+
request,
151+
completionHandler: { data, response, error in
152+
guard let httpResponse = response as? NSHTTPURLResponse
153+
where (200 <= httpResponse.statusCode && httpResponse.statusCode < 300)
154+
else {
155+
print("Bad response from server when trying to modify subscription to interest " + interest)
156+
return
157+
}
158+
callback()
153159
}
154-
callback()
155-
})
160+
)
156161

157162
task.resume()
158163
}

0 commit comments

Comments
 (0)