You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(errors): centralize 403 FORBIDDEN translation in wrapResult (#12)
* refactor(errors): centralize 403 FORBIDDEN translation in wrapResult
Lifts the local 403 try/catch out of channel/delete.ts into wrapResult
in src/lib/api.ts, so every SDK call gets uniform FORBIDDEN translation.
Adds isForbidden predicate next to isInsufficientScope; both delegate
to a shared hasCommsStatusCode helper. Callers must test
isInsufficientScope first so OAuth-scope 403s keep their dedicated
INSUFFICIENT_SCOPE code; isForbidden is the catch-all.
Ports Doist/twist-cli#247.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* refactor(errors): address PR review — exclusive isForbidden + test coverage
- Make isForbidden exclusive with isInsufficientScope so the two predicates
can be checked in any order without downgrading a scope error.
- Update isMutatingMethod mock to recognize channels.deleteChannel so the
403-translation tests actually exercise the permission-checked branch
that real delete calls use.
- Drop vi.resetModules()/per-test dynamic imports — createWrappedCommsClient
is a pure factory, so the existing top-level dynamic import suffices.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* test(errors): tighten isForbidden test name per review nit
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments