(client, sessionID)
| 402 | |
| 403 | function sdkError(result) { |
| 404 | if (!result || typeof result !== "object") return undefined |
| 405 | return result.error || result.error === null ? result.error : undefined |
| 406 | } |
| 407 | |
| 408 | function sdkData(result) { |
| 409 | if (!result || typeof result !== "object") return result |
| 410 | return Object.prototype.hasOwnProperty.call(result, "data") ? result.data : result |
| 411 | } |
| 412 | |
| 413 | function sdkErrorMessage(error) { |
| 414 | if (!error) return "unknown SDK error" |
| 415 | if (error instanceof Error) return error.message |
| 416 | if (typeof error === "string") return error |
| 417 | if (typeof error === "object") { |
| 418 | if (typeof error.message === "string") return error.message |
| 419 | if (typeof error.name === "string") return error.name |
| 420 | try { return JSON.stringify(error).slice(0, 400) } catch {} |
| 421 | } |
| 422 | return String(error) |
| 423 | } |
| 424 | |
| 425 | async function sdkCall(method, ...argsList) { |
| 426 | let firstError |
| 427 | for (const args of argsList) { |
| 428 | if (args === undefined) continue |
no test coverage detected