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

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -