How to handle error for this server call when the server is not available or is down?
func createData(request:Crudpb_CreateRequest, with completion: @escaping (String) -> Void) throws {
DispatchQueue.main.async {
self.response = try! self.client.create(request) // <---- How to handle error for this server call when the server is not available or is down?
completion(self.response.result)
}
}
It returns an object, so when I store the result in response variable then say print(response.result) it prints the response string
Please help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…