title: is there a possible way to catch no connection or timeout Exception in firestore?
body: <p>I am making my app that when it firestore tries to communicate with the server then when it fails it will display to the user that he has no connection</p>
  
  <p>first of all this code checks if the id that came from google Auth is already registered to the firestore</p>
  
  <pre><code>public FirebaseHelper CheckAccount(String id, final OnCheckAccountListener checkAccountListener){
      DocumentReference docIdRef = db.collection(Values.users).document(id);
      docIdRef.get().addOnCompleteListener(new OnCompleteListener&lt;DocumentSnapshot&gt;() {
          @Override
          public void onComplete(@NonNull Task&lt;DocumentSnapshot&gt; task) {
                  if (task.isSuccessful()){
                      DocumentSnapshot document = task.getResult();
                      checkAccountListener.AccountExist(document.exists());
                  }else{
                      if (task.getException().equals(FirebaseFirestoreException.Code.UNAVAILABLE)){
                          //Shows user that he/she is offline
                          checkAccountListener.onNoConnection();
                      }else {
                          //other catastrophic error
                          checkAccountListener.onError(task.getException().getMessage());
                      }
                  }
          }
      });
      return this;
  }
  public interface OnCheckAccountListener{
      void AccountExist(boolean itExists);
      void onNoConnection();
      void onError(String Error);
  }
  </code></pre>
  
  <p>now when i disconnect my internet then auth my account it will check the account then task.isSuccessful() is false and instead of displaying no connection like this </p>
  
  <p><a href="https://i.stack.imgur.com/8PUH1.png" rel="nofollow noreferrer">no connection dialog</a></p>
  
  <p>it shows this</p>
  
  <p><a href="https://i.stack.imgur.com/8ayPx.png" rel="nofollow noreferrer">error dialog</a></p>
  
  <p>and as you can see the reason is client is offline</p>
  
  <p>there is a possible solution but its not nice</p>
  
  <p>the solution is just </p>
  
  <pre><code>if(task.getException().getMessage().contains("offline")
  </code></pre>
  
  <p>sorry if bad explanation if you need more details just reply thx!</p>
  
  <p>and if your wondering why there is an interface in the code
  because it runs in different classes just to neat things up!
  and the pictures are customdialog
  and i also made a loading dialog like this!</p>
  
  <p><a href="https://i.stack.imgur.com/GbDxo.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>all image in the dialog are GIF's and they are awesome! </p>