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
Post a Comment