Skip to content

Commit e8fc7ac

Browse files
authored
Merge pull request #55 from IBM-Swift/swift-3.1
update error catching for swift-3.1
2 parents b055840 + 3bc6c10 commit e8fc7ac

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Sources/CouchDB/CouchDBClient.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,22 @@ public class CouchDBClient {
171171
if response.statusCode == HTTPStatusCode.OK {
172172

173173
var data = Data()
174+
#if os(Linux) && swift(>=3.1)
175+
do {
176+
try response.readAllData(into: &data)
177+
178+
let responseJSON = JSON(data: data)
179+
180+
let uuidsJSON = responseJSON["uuids"]
181+
182+
uuids = uuidsJSON.array?.flatMap({ (uuidJSON) -> String? in
183+
return uuidJSON.string
184+
})
185+
186+
} catch let caughtError {
187+
error = caughtError as? NSError ?? NSError(domain: caughtError.localizedDescription, code: -1)
188+
}
189+
#else
174190
do {
175191
try response.readAllData(into: &data)
176192

@@ -185,6 +201,7 @@ public class CouchDBClient {
185201
} catch let caughtError as NSError {
186202
error = caughtError
187203
}
204+
#endif
188205
} else {
189206
error = CouchDBUtils.createError(response.statusCode, id: nil, rev: nil)
190207
}

0 commit comments

Comments
 (0)