when a password is not entered by user, i was expecting fault code 3011
instead, the app crashed w/ this stack trace:
/AndroidRuntime: FATAL EXCEPTION: main
Process: io.frameview.buzd.buzd, PID: 8039
java.lang.IllegalArgumentException: User password cannot be null or empty.
at com.backendless.UserService.checkUserToBeProper(UserService.java:673)
at com.backendless.UserService.register(UserService.java:95)
at io.fram.buz.buz.SignUpFragment.signUpOrLogIn(SignUpFragment.java:225)
at io.fram.buz.buz.SignUpFragment.access$300(SignUpFragment.java:33)
at io.fram.buz.buz.SignUpFragment$4.onClick(SignUpFragment.java:168)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
When the password is missing a remote call is not made, instead the client library raises IllegalArgumentException. All you need to do is handle that exception:
try
{
Backendless.UserService.register( userObj );
}
catch( java.lang.IllegalArgumentException ex )
{
// handle the error here
}
not to belabor the point, but when I use UserService.login; and no password is entered, it does send back a fault code: ironically “IllegalArgumentException”, as opposed to throwing the actual exception.
02-22 14:58:51.883 17836-17836/io.fram.buz.buz I/System.out: phone is null & password is null
02-22 14:58:51.883 17836-17836/io.fram.buz.buz I/System.out: error code is: IllegalArgumentException
02-22 14:58:51.883 17836-17836/io.fram.buz.buz I/System.out: error msg is: User login cannot be null or empty.
02-22 14:59:06.213 17836-17836/io.fram.buz.buz I/System.out: phone is 408 & password is null
02-22 14:59:06.213 17836-17836/io.fram.buz.buz I/System.out: error code is: IllegalArgumentException
02-22 14:59:06.213 17836-17836/io.fram.buz.buz I/System.out: error msg is: User password cannot be null or empty.