public static string app42userName = TOTtester";
public string oldPwd = "badpassword";
public string newPwd = "anewpassword";
userService.ChangeUserPassword(app42userName, oldPwd, newPwd, new 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.