From 1e6106e8652788d138823a728cd71f2090627560 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 31 Jul 2026 21:18:11 +0300 Subject: [PATCH] pin the matchXrpcError pattern for the lexicon codegen followup Co-Authored-By: Claude Fable 5 --- src/screens/Signup/state.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/screens/Signup/state.ts b/src/screens/Signup/state.ts index 762597e5c8..33a5d26a64 100644 --- a/src/screens/Signup/state.ts +++ b/src/screens/Signup/state.ts @@ -261,8 +261,22 @@ function classifyExpectedSignupError(e: unknown): string | undefined { /* * TODO: `XrpcResponseError.error` is the open `LexErrorCode` union, so these * codes are compared as plain strings and a typo silently never matches. - * Narrowing to the errors `com.atproto.server.createAccount` declares needs - * the generated lexicons. + * Once the generated lexicons land, replace this (and every multi-code error + * site) with a shared helper that narrows against the method schema: + * + * function matchXrpcError( + * e: unknown, + * method: Main, + * ): InferMethodError | undefined + * + * switch (matchXrpcError(e, com.atproto.server.createAccount)) { + * case 'InvalidHandle': ... + * } + * + * The return type is the method's declared-errors union, so a typo'd case is + * a compile error, and undeclared codes fall through to `undefined`. The + * helper should also match `e.method.nsid` so a declared code from a + * different call cannot match, mirroring the old per-method error classes. */ if (e instanceof XrpcResponseError) { switch (e.error) {