question

Sabin george avatar image
Sabin george asked

GetLeaderboard and callbacks

Hi Playfab Support Team

I am getting strange behaviour on GetLeaderboard method.  Don't know why OnPlayFabError callback invokes just after OnGetLeaderBoardSuccess callback, it shouldn't happen. 

PlayFabClientAPI.GetLeaderboard (request,OnGetLeaderBoardSuccess,OnPlayFabError);

public void OnPlayFabError(PlayFabError error)

{

   Debug.Log (error.HttpStatus) prints Client failed to       parse response from server;

  Debug.Log (error.ErrorMessage); prints

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at PlayfabLeaderboardController.OnGetLeaderBoardSuccess (PlayFab.ClientModels.GetLeaderboardResult result) [0x0005e] in /Volumes/Local Disk/Projects/ResearchLab/PlayFabInsaneEaglesLeaderboard/Assets/Scripts/PlayfabLeaderboardController.cs:93
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000d0] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
--- End of inner exception stack trace ---
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x000eb] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000b9] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Delegate.cs:443
at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00018] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/MulticastDelegate.cs:71
at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Delegate.cs:415
at PlayFab.Internal.ResultContainer`1[PlayFab.ClientModels.GetLeaderboardResult].HandleResults (PlayFab.CallRequestContainer callRequest, System.Delegate resultCallback, PlayFab.ErrorCallback errorCallback, System.Action`2 resultAction) [0x00093] in /Volumes/Local Disk/Projects/ResearchLab/PlayFabInsaneEaglesLeaderboard/Assets/PlayFabSDK/Internal/ResultContainer.cs:53
UnityEngine.Debug:Log(Object)
PlayfabLeaderboardController:OnPlayFabError(PlayFabError) (at Assets/Scripts/PlayfabLeaderboardController.cs:101)
PlayFab.Internal.ResultContainer`1:HandleResults(CallRequestContainer, Delegate, ErrorCallback, Action`2) (at Assets/PlayFabSDK/Internal/ResultContainer.cs:84)
PlayFab.<GetLeaderboard>c__AnonStorey7A:<>m__77(CallRequestContainer) (at Assets/PlayFabSDK/Public/PlayFabClientAPI.cs:943)
PlayFab.CallRequestContainer:InvokeCallback() (at Assets/PlayFabSDK/Public/PlayFabErrors.cs:255)
PlayFab.Internal.<MakeRequestViaUnity>c__Iterator2:MoveNext() (at Assets/PlayFabSDK/Internal/PlayFabHTTP.cs:260)

}

Thanks

Sabin George

 

 

 

 

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

The issue in this case is up near the top of the error output:

 

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
at PlayfabLeaderboardController.OnGetLeaderBoardSuccess (PlayFab.ClientModels.GetLeaderboardResult result) [0x0005e] in /Volumes/Local

 

What's happening is that your OnGetLeaderBoardSuccess function is throwing an exception due to a null reference. This is then resulting in the error callback being invoked, as our try/catch is checking for issues in our own code, but what's happening is that in your code, which we dynamically invoke, the exception causes us to proceed to that catch. We're going to put an additional try around the invocation call, to catch situations like this and pass back more details about the specifics of the error we get back from the call to your function.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sabin george avatar image
Sabin george answered

Thanks  Brendan

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.