Why can't I get the message out of an App42Exception in case of userService.ChangeUserPassword()

0 votes

public static string app42userName = TOTtester";  

public string oldPwd = "badpassword";

public string newPwd = "anewpassword";

userService.ChangeUserPassword(app42userNameoldPwdnewPwdnew UserPwdChange()); 
 
To test I intentionally generate an exception by entering the WRONG password for the 'oldPwd'.
it should generate an exception in the UserPwdChange()callback:
 

 

public class UserPwdChange : App42CallBack
{
        private string result = "";
 
       public void OnSuccess(object response)
       {
              // do something
       }
 
   int ctr = 1;
 
       public void OnException(Exception e)
       {
      Debug.Log (ctr++ +" times through\n");
 
              Debug.Log ("Exception is : " + e);         // This prints out a proper message including a JSON format string
 
              App42Exception exception = (App42Exception)e;
              int appErrorCode = exception.GetAppErrorCode();
 
              string fetchedJSONObject = exception.GetMessage();                              // this returns a null
 
              Debug.Log ("fetchedJSONObject is : " + fetchedJSONObject +"\n");       // shows nothing because it is null
              JObject jsonObj = JObject.Parse(fetchedJSONObject);                              // of course it gives error shown below
       }
}
 
"NullReferenceException: Object reference not set to an instance of an object"
 
Anyway this only happens in the case of ChangeUserPassword().
I also noticed that the OnException() function is called twice because I was seeing two errors for each call. I confirmed this by putting a counter in it and increasing it on each pass and printing its value to the Unity editor console.
asked Jul 1, 2014 in App42 Cloud API-BaaS by huffman (17 points)
edited Jul 1, 2014 by huffman

1 Answer

0 votes
Hi,

Thanks for writing us.

Its look like there is some issue with this method. You can continue with your developement for this scenario only.

We will update this on Our end ASAP & let you know for the same.

Also can you share the details when you are having twice counter in onException because we can't find such issue for that.

Thanks.
answered Jul 1, 2014 by hs00105 (517 points)
I added the counter in the source code in the original post. It is in blue bold text. Just one call of:

userService.ChangeUserPassword(app42userName, oldPwd, newPwd, new UserPwdChange());

will cause this output:

1 times through

Exception is : com.shephertz.app42.paas.sdk.csharp.App42Exception: {"httpErrorCode":"400", "appErrorCode":"2003", "message":"BAD REQUEST", "details":"Old Password is not matching for user 'TOTtester'."}

2 times through

Exception is : com.shephertz.app42.paas.sdk.csharp.App42Exception: System.NullReferenceException: Object reference not set to an instance of an object
  at SimpleJSON.JObject.Parse (System.String aJSON) [0x00000] in <filename unknown>:0

NullReferenceException: Object reference not set to an instance of an object
SimpleJSON.JObject.Parse (System.String aJSON)
We are working on this issue(Object reference not set to an instance of an object) and fix it ASAP & let you know when it will be update.
Thanks.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...