Skip to main content
The error type thrown by the Swift SDK is 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 from error.baseCode
  • Get the English description from error.message; error.localizedDescription outputs "<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 103 and the macOS prefix is 105; for example, missing camera permission on iOS is 103231
  • 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 the statusCode of apiRequestFailed and 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 / localizedDescription are always in English, meant for developers and logs; for messages shown to end users, map code / baseCode yourself—don’t show message directly
  • SRTCEngine.language (such as "en" or "zh-CN"; nil follows the system language) sets the Accept-Language header 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.
SRTCError is distributed with library evolution enabled, and later versions may add cases; keep a default branch in your switch.