Skip to content

Commit f9a956b

Browse files
committed
chore: regenerate sdk
1 parent 4684384 commit f9a956b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

Sources/Appwrite/Client.swift

+10-2
Original file line numberDiff line numberDiff line change
@@ -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)