SRTCError, a Swift enum with semantic cases that also provides integer error codes unified across platforms:
- Branch on cases with
switch - Get the full error code from
error.code, and the low 3-digit semantic code fromerror.baseCode - Get the English description from
error.message;error.localizedDescriptionoutputs"<code>: <message>"
Since 1.5.0, error codes are renumbered according to the cross-platform unified table, and error messages are in English. For the mapping between the old codes (1.4.7 and earlier) and the new ones, see the Changelog.
Error code format
SRTCError.code returns the full error code:
- The SDK’s own errors: platform prefix + a 3-digit low code. The iOS prefix is
103and the macOS prefix is105; for example, missing camera permission on iOS is103231 - Server business errors (codes 1000–99999): passed through unchanged, with no prefix
- HTTP status codes are never folded into the error code: non-200 HTTP responses and network failures are always
006; the HTTP status is only in thestatusCodeofapiRequestFailedand in the description
baseCode is the low 3-digit semantic code. It means the same as on Web, Android, HarmonyOS, and other platforms, which makes it suitable for mapping user messages uniformly across platforms; for server business codes, baseCode returns the code itself.
SRTCError implements CustomNSError: once bridged to NSError, domain = "cn.seastart.srtc" and code is the full code; when there’s an original system error (such as for screenShareDenied), it’s in NSUnderlyingErrorKey. Integrations that go through NSError, such as ObjC, uni-app, or Flutter, can check the code directly.
Error language
message/localizedDescriptionare always in English, meant for developers and logs; for messages shown to end users, mapcode/baseCodeyourself—don’t showmessagedirectlySRTCEngine.language(such as"en"or"zh-CN";nilfollows the system language) sets theAccept-Languageheader on requests to the backend, and the messages of server business errors (codes 1000–99999) come back in Chinese or English accordingly; the SDK’s own errors aren’t affected
Connection
Signaling
WebRTC / transport
Tracks and capture
Engine and general errors
Virtual background
Virtual background is available on iOS only, so these four errors are thrown only on iOS. Starting with
1.7.0, macOS no longer has the virtual background APIs, but the error codes are kept and can be referenced on both platforms. For usage, see Virtual background.
Recommended error handling
SRTCError is distributed with library evolution enabled, and later versions may add cases; keep a default branch in your switch.