I am trying to make a the code that will catch a PhoneNumberInUseException that is thrown by the ServiceImpl however, the code below always go for the else statement.
@Override
public void onFailure(Throwable caught) {
Window.alert("Failed create account.");
if (caught instanceof PhoneNumberInUseException) {
Window.alert("Sorry, but the phone number is already used.");
} else {
Window.alert(caught.toString());
}
}
The PhoneNumberInUseException extends RuntimeException
Right now I am just showing this through Window.alert, however I will be doing client-side logic for handling the exception, that is why I can't simply use IllegalArgumentException which works just fine passing exception string from server to client.
Am I missing something?