(error: unknown, fallbackCode: string)
| 28 | } |
| 29 | |
| 30 | export function asStatus(error: unknown, fallbackCode: string): StoreDiagnostic { |
| 31 | if (error instanceof StoreError) { |
| 32 | return error.diagnostic; |
| 33 | } |
| 34 | // RootSelectionError (and siblings) carry the same envelope without |
| 35 | // sharing a class hierarchy; duck-type the diagnostic once, here. |
| 36 | const diagnostic = (error as { diagnostic?: StoreDiagnostic }).diagnostic; |
| 37 | if (diagnostic && typeof diagnostic.code === 'string') { |
| 38 | return diagnostic; |
| 39 | } |
| 40 | return { |
| 41 | severity: 'error', |
| 42 | code: fallbackCode, |
| 43 | message: asErrorMessage(error), |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | export function emitFailure( |
| 48 | json: boolean | undefined, |
no test coverage detected