Skip to content

Commit 0b2fc71

Browse files
authored
Merge pull request #29 from appwrite/dev
chore: regenerate sdk
2 parents 5144b42 + f9a956b commit 0b2fc71

File tree

105 files changed

+2927
-727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2927
-727
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Add the package to your `Package.swift` dependencies:
3333

3434
```swift
3535
dependencies: [
36-
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "7.0.0"),
36+
.package(url: "[email protected]:appwrite/sdk-for-swift.git", from: "8.0.0"),
3737
],
3838
```
3939

Sources/Appwrite/Client.swift

+11-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ open class Client {
2121
"x-sdk-name": "Swift",
2222
"x-sdk-platform": "server",
2323
"x-sdk-language": "swift",
24-
"x-sdk-version": "7.0.0",
24+
"x-sdk-version": "8.0.0",
2525
"x-appwrite-response-format": "1.6.0"
2626
]
2727

@@ -337,20 +337,24 @@ open class Client {
337337
var message = ""
338338
var data = try await response.body.collect(upTo: Int.max)
339339
var type = ""
340+
var responseString = ""
340341

341342
do {
342343
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
343344

344345
message = dict?["message"] as? String ?? response.status.reasonPhrase
345346
type = dict?["type"] as? String ?? ""
347+
responseString = String(decoding: data.readableBytesView, as: UTF8.self)
346348
} catch {
347349
message = data.readString(length: data.readableBytes)!
350+
responseString = message
348351
}
349352

350353
throw AppwriteError(
351354
message: message,
352355
code: Int(response.status.code),
353-
type: type
356+
type: type,
357+
response: responseString
354358
)
355359
}
356360

@@ -434,20 +438,24 @@ open class Client {
434438
default:
435439
var message = ""
436440
var type = ""
441+
var responseString = ""
437442

438443
do {
439444
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
440445

441446
message = dict?["message"] as? String ?? response.status.reasonPhrase
442447
type = dict?["type"] as? String ?? ""
448+
responseString = String(decoding: data.readableBytesView, as: UTF8.self)
443449
} catch {
444450
message = data.readString(length: data.readableBytes)!
451+
responseString = message
445452
}
446453

447454
throw AppwriteError(
448455
message: message,
449456
code: Int(response.status.code),
450-
type: type
457+
type: type,
458+
response: responseString
451459
)
452460
}
453461
}

Sources/Appwrite/Models/AppwriteError.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ open class AppwriteError : Swift.Error, Decodable {
55
public let message: String
66
public let code: Int?
77
public let type: String?
8+
public let response: String
89

9-
init(message: String, code: Int? = nil, type: String? = nil) {
10+
init(message: String, code: Int? = nil, type: String? = nil, response: String = "") {
1011
self.message = message
1112
self.code = code
1213
self.type = type
14+
self.response = response
1315
}
1416
}
1517

0 commit comments

Comments
 (0)