(fault: BridgeFault, context: string)
| 94 | } |
| 95 | |
| 96 | function throwFault(fault: BridgeFault, context: string): never { |
| 97 | logForDebugging( |
| 98 | `[bridge:debug] Injecting ${fault.kind} fault into ${context}: status=${fault.status} errorType=${fault.errorType ?? 'none'}`, |
| 99 | ) |
| 100 | if (fault.kind === 'fatal') { |
| 101 | throw new BridgeFatalError( |
| 102 | `[injected] ${context} ${fault.status}`, |
| 103 | fault.status, |
| 104 | fault.errorType, |
| 105 | ) |
| 106 | } |
| 107 | // Transient: mimic an axios rejection (5xx / network). No .status on |
| 108 | // the error itself — that's how the catch blocks distinguish. |
| 109 | throw new Error(`[injected transient] ${context} ${fault.status}`) |
| 110 | } |
| 111 | |
| 112 | return { |
| 113 | ...api, |
no test coverage detected