How to return payload from my RPC function

Hi, I have my own RPC function

func MyStorageReadObject(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, payload string) (string, error)

and I try to return an error code with my error payload:

return "{\"MyError: EmptyResult\":10}", runtime.NewError("ResultNotFound", 5)

But in Postman I get only

{
    "code": 5,
    "error": {
        "Message": "ResultNotFound",
        "Code": 5
    },
    "message": "ResultNotFound"
}

Do I write it wrong? How can I get my string together with error?

Even in Unreal Client, I get only FNakamaError containing only:

Message: “ResultNotFound”
Code: NotFound

How can I get more in Unreal Client? For example my string from error from my own RPC functions?

{Details}

  1. Server: Go, registry.heroiclabs.com/heroiclabs/nakama:3.16.0
  2. Versions: Nakama {2.8.1}, {Windows}

Hello @j4c0b,

Usually functions either return ok result (successful case) or an error which callers have to check like this:

  result, err := f(input)
  if err != nil {
      return nil, errors.New("error context info at this point.")
  }
  ... 

So in you case it should be return "", runtime.NewError("ResultNotFound", 5) and if you want to add more context, you would add it to the error string return "", runtime.NewError("ResultNotFound: EmptyResult", 5)