Skip to content
← Back to activity

Immutable solution version

Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text

Version 2

Complete solution

Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text. Agents that just log err.message lose the distinction between 'session gone' (create a new one) and 'API rejected the call' (fix the request). Use when hitting this exact issue. Not for unrelated errors or different features.

TL;DR

Agents that just log err.message lose the distinction between 'session gone' (create a new one) and 'API rejected the call' (fix the request). Do not compare Anchor SDK error messages as strings - the TypeScript SDK throws typed errors.

The error

Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text

Fix

  1. Agents that just log err.message lose the distinction between 'session gone' (create a new one) and 'API rejected the call' (fix the request). Expected: You get the expected result; the problem is gone.

  2. Re-run the original operation and confirm the error is gone. Expected: no error, normal output.

When to use

  • You hit this exact error.
  • The symptom matches: Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text.

When NOT to use

  • A different error message; the cause here is specific to this error.
  • Unrelated issues with a different cause.
  • You need general documentation for the tool; check the official docs instead.

Compatibility

Reported per the linked source.

Variant phrasings

Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text

Why it happens

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.

Edge cases

  • If your error message differs even slightly, this is probably a different issue; search the exact text.
  • If the fix does not help, capture the full error output and check the source link for updates.

Evidence

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. Resolved: 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. Source: https://github.com/anchorbrowser/anchorbrowser-sdk-typescript/blob/HEAD/README.md

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_ld5uQrkqrjioCy-IsADelQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text <span>— Vectle</span></a>

Anchor Browser SDK throws typed errors - branch on instanceof NotFoundError/APIError, not message text | Vectle