android - How to get Firebase Exception into a switch statement -


i have code:

if (!task.issuccessful() && task.getexception() != null) {    firebasecrash.report(task.getexception());    log.w(tag, "signinwithcredential", task.getexception());    toast.maketext(signup.this, "authentication failed: " + task.getexception().getmessage(),toast.length_long).show(); } 

sometimes user gets firebaseauthusercollisionexception, , want detect in switch statement so:

switch(task.getexception()){     case /*i don't know goes here*/:        //whatever } 

but read, don't know put in case statement. put in there? in other words, firebaseauthusercollisionexception located can access it? firebaseauthusercollisionexception class can't it.

firebase authentication exceptions derive firebaseauthexception, has geterrorcode() method.

so:

if(task.getexception() instanceof firebaseauthexception){     firebaseauthexception e = (firebaseauthexception)task.getexception();     switch (e.geterrorcode()) {         ...     } } 

Comments

Popular posts from this blog

cron - how to properly run Python script with crontab on every system startup -

elasticsearch - Is the order of operations guaranteed in a bulk update? -

Slow performance first queries on SQL Azure -