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
Browse filesBrowse the repository at this point in the historyBrowse files
authored
types: improve type safety in error handling — replace as-casts with type guards (#4638)
`catch` bindings and query `error` fields are `unknown` — the thrower picks
the shape. Nine sites asserted one anyway (`(error as Error).message`,
`error as Error`, `error as { status?: number }`), so a thrown string gave
`undefined` where a string was expected and a thrown `null` crashed the
handler that was meant to report it.
Replaces those assertions with structural narrowing: `getErrorMessage` in
web's `errorHandling.ts`, `toError`/`messageOf` local to mobile's
WebSocketManager, and inline guards where a single site reads a single field.
The one behavior difference is on inputs that already misbehaved: a thrown
`null` now falls through to the retry path instead of throwing a TypeError
inside the catch block.
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
0 commit comments