ClassCastException in switch android -


i receiving classcastexception error while doing switch in code:

private void performlogin(string email, string pass, string version, string platform) {         if (viewisattached()) {             getview().showprogress();              modellogin.login(email, pass, version, platform, new onstatechangelistener() {                 @override                 public void oncompleted() {                     if (viewisattached()) getview().hideprogress();                 }                  @override                 public void onerror(apierror error) {                     if (viewisattached()) {                         switch (error.getcode()){  //error in line                             case 418: //update                                 getview().openupdatedialog();                                 break;                             case http_bad_request:                                 getview().showinvalidusererror();                                 break;                             default:                                 getview().showerrorgeneral();                                 break;                         }                     }                 }                  @override                 public void onsuccess(responselogin data) {                     //go home                 }             });         }     } 

unfortunately error cannot reproduce in fabric getting error in several devices , cannot figure out why.

com.omnidoctor.omniapp.screens.login.loginpresenter$1.onerror (loginpresenter.java:103)  com.omnidoctor.omniapp.screens.login.loginmodel$1.onerror (loginmodel.java:45)  rx.observers.safesubscriber._onerror (safesubscriber.java:153)  rx.observers.safesubscriber.onerror (safesubscriber.java:115)  rx.internal.operators.operatorobserveon$observeonsubscriber.checkterminated (operatorobserveon.java:273)  rx.internal.operators.operatorobserveon$observeonsubscriber.call (operatorobserveon.java:216)  rx.android.schedulers.looperscheduler$scheduledaction.run (looperscheduler.java:107)  android.os.handler.handlecallback (handler.java:739)  com.android.internal.os.zygoteinit.main (zygoteinit.java:740) 

this error having , line happens

switch (error.getcode())

update:

apierror class:

public class apierror extends throwable {      private final throwable error;      public apierror(throwable e) {         super(e);         this.error = e;     }      public boolean isauthfailure() {         return error instanceof httpexception && ((httpexception) error).code() == http_unauthorized;     }      public boolean isuserinvalid() {         return error instanceof httpexception && ((httpexception) error).code() == http_bad_request;     }      public boolean appshouldupdate() {         return error instanceof httpexception && ((httpexception) error).code() == 418;     }      public boolean isresponsenull() {         return error instanceof httpexception && ((httpexception) error).response() == null;     }      public int getcode(){         return ((httpexception) error).code();     } } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -