Find the error codes?

We’re trying to catch when a join match fails because the match id is not valid (When a match has ended and a player is trying to re-join it).

Looking at this code: https://github.com/heroiclabs/nakama/blob/master/server/pipeline_match.go

It shows that all errors for joinMatch give. “Code: int32(rtapi.Error_BAD_INPUT)”. So no matter the error we always get the same error code.

And then by looking here: https://github.com/heroiclabs/nakama-common/blob/master/rtapi/realtime.pb.go you can see: Error_BAD_INPUT Error_Code = 3

But when logging the error code in unity it says 60.

Would be really useful if the client library included the error codes. So we could do if(errorCode == Nakama.ErrorCodes.BadInput).

Are the error codes listed in some documentation even? Feels a bit risky to just compare it to 60 because it kinda seems like that’s the error, although the rtapi tells us it’s 3.

Thanks!

@NixarnTowerPop Thanks for the suggestion. We can definitely improve how we surface error codes from the socket API. In the meantime could you share the response output message you see in Unity where you get the error 60 value?

Sure, so here’s how to replicate it (adding some random match id that will fail):

 try {
      return await _connection.Socket.JoinMatchAsync("abc");
  }
  catch (WebSocketException e) {
      Debug.Log(e.ErrorCode);               
  }

that gives the output of 60

@NixarnTowerPop Ok thanks. Which version of the client library for Unity are you using?

We’re using v2.9.5

@novabyte any update on this?

@NixarnTowerPop I had a look at the .NET code and have a better idea of what we’d need to do to expose the error information into the exception type for you to have targeted error codes. Please can you open a feature request for the change:

GitHub - heroiclabs/nakama-dotnet: .NET client for Nakama server written in C#.

1 Like