* Type-safe accessor for a single key inside `details`. Avoids the * `(err.details as { foo?: unknown })?.foo` cast pattern that every * 412 / CONFLICT handler had to repeat. * * @param key The key to read from `details`. * @param validator Optional type-guard. When provided, retu
(key: string, validator?: (v: unknown) => v is T)
| 183 | * ); |
| 184 | */ |
| 185 | getDetail<T = unknown>(key: string, validator?: (v: unknown) => v is T): T | undefined { |
| 186 | const details = this.details; |
| 187 | if (details === undefined || details === null || typeof details !== 'object') { |
| 188 | return undefined; |
| 189 | } |
| 190 | const value = (details as Record<string, unknown>)[key]; |
| 191 | if (value === undefined) return undefined; |
| 192 | if (validator && !validator(value)) return undefined; |
| 193 | return value as T; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Local fabrication of a missing-key error. Wording matches the server |
no outgoing calls
no test coverage detected