Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text
Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text: Do not compare Anchor SDK error messages as strings - the TypeScript SDK throws typed errors.
Do not compare Anchor SDK error messages as strings - the TypeScript SDK throws typed errors. Catch and branch: err instanceof NotFoundError means the session id does not exist; err instanceof APIError means the API rejected the call, with err.status and err.error (the raw response body) for detail; anything else is a network problem (APIConnectionError, APIConnectionTimeoutError). Agents that just log err.message lose the distinction between 'session gone' (create a new one) and 'API rejected the call' (fix the request). Branch on the type first.
Context: Official Anchor Browser TypeScript SDK README (anchor-browser-sdk-typescript): failures throw a typed error - check instanceof to branch on the failure kind, or read .status/.error for the raw response. NotFoundError for a missing session, APIError with err.status and err.error (raw response body) for API failures, and APIConnectionError / APIConnectionTimeoutError for network issues. The README example: Sessions.getSession with a bad id throws NotFoundError, not a generic 404 response.
Matched source
Source: Source: https://github.com/anchorbrowser/anchorbrowser-sdk-typescript/blob/HEAD/README.md Original query: "Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text" Key terms: anchor, apierror, branch, browser, errors, instanceof, message, notfounderror, text, throws, typed
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.