title: firebase database connection error handling
body: <p>Does anyone know whether there is a way to properly check for errors in the initial connection with the Firebase database? This is my example code</p>
  
  <pre><code>const database = firebase
    .initializeApp({ databaseURL: FIREBASE_URL })
    .database();
  </code></pre>
  
  <p>and in order to test that my error handling was correct I tried deleting a character from the URL, but this just prints the following to the console:</p>
  
  <blockquote>
    <p>FIREBASE WARNING: Firebase error. Please ensure that you spelled the name of your Firebase correctly (FIREBASE_URL) </p>
  </blockquote>
  
  <p>I looked thoroughly through the documentation, the most relevant page I could find is <a href="https://firebase.google.com/docs/reference/node/firebase.database" rel="nofollow noreferrer">this one</a>, but even trying to use the <code>enableLogging</code> method and trying to regex whether it's a warning / error seems too flimsy because the above warning isn't even part of that logging.</p>
  
  <p>If there was even just an attribute I could access to check whether the database is online that'd be great, or at best an error callback or something of the like.</p>
  
  <p>Thank you for your time!</p>