| | | 1 | | import { SecretsFetchError } from '../../../core/domain/errors/DomainErrors.js'; |
| | | 2 | | import { describeError } from '../../../core/infrastructure/describeError.js'; |
| | | 3 | | |
| | | 4 | | /** |
| | | 5 | | * Renders an error into log lines for the GitHub Action, keeping the |
| | | 6 | | * retro-arcade tone used across Envilder's failure messages. Returns |
| | | 7 | | * one entry per log line so the caller can emit each via `ILogger.error`. |
| | | 8 | | */ |
| | | 9 | | export function presentGhaError(error: unknown): string[] { |
| | 10 | 10 | | if (error instanceof SecretsFetchError) { |
| | 3 | 11 | | return renderSecretsFetchError(error); |
| | | 12 | | } |
| | 7 | 13 | | return renderFallback(error); |
| | | 14 | | } |
| | | 15 | | |
| | | 16 | | function renderSecretsFetchError(error: SecretsFetchError): string[] { |
| | 3 | 17 | | const failureLines = error.failures.map( |
| | 5 | 18 | | (failure) => ` \u2717 ${failure.envVar} \u2192 ${failure.path}`, |
| | | 19 | | ); |
| | 5 | 20 | | const reasons = [...new Set(error.failures.map((failure) => failure.reason))]; |
| | | 21 | | |
| | 3 | 22 | | return [ |
| | | 23 | | '\u{1F4A5} GAME OVER \u2014 some secrets could not be fetched', |
| | | 24 | | ...failureLines, |
| | | 25 | | '', |
| | | 26 | | '\u2B50 WHY?', |
| | 4 | 27 | | ...reasons.map((reason) => ` ${reason}`), |
| | | 28 | | ]; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | function renderFallback(error: unknown): string[] { |
| | 7 | 32 | | const message = describeError(error); |
| | 7 | 33 | | return [ |
| | | 34 | | '\u{1F6A8} GAME OVER \u2014 fell down the wrong pipe! \u{1F344}\u{1F4A5}', |
| | | 35 | | message, |
| | | 36 | | ]; |
| | | 37 | | } |