# How to return payload from my RPC function

**URL:** <https://forum.heroiclabs.com/t/how-to-return-payload-from-my-rpc-function/4348>\
**Category:** Client Libraries\
**Tags:** sdk-unreal, golang\
**Created:** [September 15, 2023, 9:05am UTC](https://forum.heroiclabs.com/t/how-to-return-payload-from-my-rpc-function/4348 "2023-09-15T09:05:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![j4c0b](https://avatars.discourse-cdn.com/v4/letter/j/3ab097/32.png) [@j4c0b](https://forum.heroiclabs.com/u/j4c0b)\
**Post date:** [September 15, 2023, 9:05am UTC](https://forum.heroiclabs.com/t/how-to-return-payload-from-my-rpc-function/4348/1 "2023-09-15T09:05:04Z")

</div>

Hi, I have my own RPC function

```auto
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:

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

```

But in Postman I get only

```auto
{
    "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](http://registry.heroiclabs.com/heroiclabs/nakama:3.16.0)
2. Versions: Nakama {2.8.1}, {Windows}

---

<div class="post-metadata">

**Author:** ![flavio](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/flavio/32/2161_2.png) [@flavio](https://forum.heroiclabs.com/u/flavio)\
**Post date:** [September 15, 2023, 12:56pm UTC](https://forum.heroiclabs.com/t/how-to-return-payload-from-my-rpc-function/4348/2 "2023-09-15T12:56:20Z")

</div>

Hello @j4c0b,

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

```go
  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)`
