java - How to differentiate between server errors and integrity constraint exceptions when using RPC? -


i have method on server side talking communicating client side code through rpc.

@override public void registerstudent(param1, param2...) throws illegalargumentexception {      //some code here      try {         //some code here     } catch (constrainterrorviolationexception e) {         throw new registerfailedexception();     } } 

i have chunk of code handling failures.

@override public void onfailure(throwable caught) {     displayerrorbox("could not register user", caught.getmessage()); } 

currently, onfailure() function not differentiate between random exceptions , specific exception looking deal , handle, registerfailedexception.

how can handle 2 different sort of errors properly?

so exception

public class registerfailedexception extends runtimeexception {      public registerfailedexception () {         super();     } } 

and method throws exception

throws new registerfailedexception(); 

then in onfailure() check

if (caught instanceof registerfailedexception){  } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -