Exception Handeling
- in swift exceptions are represented by instance of the
Errorprotocol or its subtype. - we are using
do-catchblock to handle the exceptions.Trykeyword is used before the call because it might throw an error.
do {
let user = try await realmApp.login(credentials: .anonymous)
username = user.id
} catch {
print("Failed to login to Realm : \(error.localizedDescription)")
}