Skip to content

C API: Results and errors

sona_result is the return code of almost every call. SONA_OK is 0, SONA_PENDING is 1 (not finished; call again after sona_update), and every error is negative:

Code Value When
SONA_E_UNSUPPORTED -1 No usable backend, API version or feature
SONA_E_ORIGIN -2 Web only; kept so codes line up with the web SDK
SONA_E_LICENCE -3 The app has not accepted the SDK Licence, or the licence file is missing or bad
SONA_E_APP -4 No such app, or it was turned off
SONA_E_GATE -5 360sona could not be reached
SONA_E_MANIFEST -6 That avatar could not be read or built
SONA_E_CONTEXT -7 The graphics device failed or was lost
SONA_E_READBACK -8 A picture could not be read back
SONA_E_LIMIT -9 Too many avatars or requests, over the daily use, or over the memory budget
SONA_E_DESTROYED -10 The ctx, avatar or renderer is gone
SONA_E_PLATFORM -11 This build is not licensed for this platform
SONA_E_BUILD -12 This build was revoked; download a new one
SONA_E_ARGUMENT -13 A bad argument
SONA_E_MEMORY -14 The allocator returned NULL
SONA_E_NOT_FOUND -15 No source has that asset
SONA_E_IO -16 A source failed; a retry may work
SONA_E_CORRUPT -17 Bytes did not decode
SONA_E_NOT_READY -18 The avatar is not ready
SONA_E_UNIMPLEMENTED -19 Not in this build

sona_error_info holds code, message and fix: what went wrong and what to do about it.

sona_result_name

const char *sona_result_name(sona_result r);
Parameter and type Meaning
r
sona_result
A result code

Returns const char *.

Example (also in Troubleshooting and error codes):

sona_config_defaults(&cfg);   /* then the licence and the sources */
sona_result r = sona_open(&cfg, &ctx);
if (r != SONA_OK) {
  sona_error_info e = sona_last_error(NULL);
  fprintf(stderr, "%s (%d): %s\n  %s\n", sona_result_name(r), (int)r,
          e.message, e.fix ? e.fix : "");
}

The name of a code ("licence", "gate", ...): the same words as the web SDK's SonaError.code.

sona_last_error

sona_error_info sona_last_error(const sona_ctx *ctx);
Parameter and type Meaning
ctx
const sona_ctx *
The context (required)

Returns sona_error_info.

Example (also in Troubleshooting and error codes):

sona_config_defaults(&cfg);   /* then the licence and the sources */
sona_result r = sona_open(&cfg, &ctx);
if (r != SONA_OK) {
  sona_error_info e = sona_last_error(NULL);
  fprintf(stderr, "%s (%d): %s\n  %s\n", sona_result_name(r), (int)r,
          e.message, e.fix ? e.fix : "");
}

The last error on a ctx. Its strings live until the next error.

This page as Markdown · All the docs as one file (llms-full.txt)