Skip to content

Commit

Permalink
Merge pull request #716 from appwrite/fix-apple-error-type
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar authored Sep 11, 2023
2 parents 9e23c22 + a49893e commit 058987c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion templates/swift/Sources/Client.swift.twig
Original file line number Diff line number Diff line change
Expand Up @@ -301,18 +301,21 @@ open class Client {
default:
var message = ""
var data = try await response.body.collect(upTo: Int.max)
var type = ""

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

message = dict?["message"] as? String ?? response.status.reasonPhrase
type = dict?["type"] as? String ?? ""
} catch {
message = data.readString(length: data.readableBytes)!
}

throw {{ spec.title | caseUcfirst }}Error(
message: message,
code: Int(response.status.code)
code: Int(response.status.code),
type: type
)
}
}
Expand Down

0 comments on commit 058987c

Please sign in to comment.