I need to handle "Permission Denied" error differently from all other errors.
In Android I've done it: (Kotlin)
override fun onCancelled(error: DatabaseError) {
if (error.code == DatabaseError.PERMISSION_DENIED) {
// Warn user
}
}
In iOS I have only:
someDbReference.observe(.childAdded, with: { data in
// Do something
}, withCancel: { err in
// err is Error
print((err as NSError).code) // 1
// Which error? O_o
})
How to determine error type? I've read whole documentation, and I think that err.localizedDescription == "Permission Denied" is a really bad way.