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