envilder
Version:
A CLI and GitHub Action that securely centralizes your environment variables from AWS SSM or Azure Key Vault as a single source of truth
32 lines • 1.24 kB
JavaScript
import { SecretsFetchError } from '../../../core/domain/errors/DomainErrors.js';
import { describeError } from '../../../core/infrastructure/describeError.js';
/**
* Renders an error into log lines for the GitHub Action, keeping the
* retro-arcade tone used across Envilder's failure messages. Returns
* one entry per log line so the caller can emit each via `ILogger.error`.
*/
export function presentGhaError(error) {
if (error instanceof SecretsFetchError) {
return renderSecretsFetchError(error);
}
return renderFallback(error);
}
function renderSecretsFetchError(error) {
const failureLines = error.failures.map((failure) => ` \u2717 ${failure.envVar} \u2192 ${failure.path}`);
const reasons = [...new Set(error.failures.map((failure) => failure.reason))];
return [
'\u{1F4A5} GAME OVER \u2014 some secrets could not be fetched',
...failureLines,
'',
'\u2B50 WHY?',
...reasons.map((reason) => ` ${reason}`),
];
}
function renderFallback(error) {
const message = describeError(error);
return [
'\u{1F6A8} GAME OVER \u2014 fell down the wrong pipe! \u{1F344}\u{1F4A5}',
message,
];
}
//# sourceMappingURL=GhaErrorPresenter.js.map