< Summary - Envilder CLI

Information
Class: src/envilder/core/domain/errors/DomainErrors.ts
Assembly: Default
File(s): src/envilder/core/domain/errors/DomainErrors.ts
Tag: 427_29134414720
Line coverage
86%
Covered lines: 13
Uncovered lines: 2
Coverable lines: 15
Total lines: 104
Line coverage: 86.6%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/envilder/core/domain/errors/DomainErrors.ts

#LineLine coverage
 1/**
 2 * Base class for all domain-specific errors in the application.
 3 */
 4export class DomainError extends Error {
 5  constructor(message: string) {
 706    super(message);
 707    this.name = this.constructor.name;
 708    Error.captureStackTrace(this, this.constructor);
 9  }
 10}
 11
 12/**
 13 * Error thrown when required arguments are missing or invalid.
 14 */
 15export class InvalidArgumentError extends DomainError {}
 16
 17/**
 18 * Error thrown when a required dependency is missing.
 19 */
 20export class DependencyMissingError extends DomainError {}
 21
 22/**
 23 * Error thrown when a secret operation fails.
 24 */
 25export class SecretOperationError extends DomainError {}
 26
 27/**
 28 * Error thrown when an environment file operation fails.
 29 */
 30export class EnvironmentFileError extends DomainError {}
 31
 32/**
 33 * Error thrown when a parameter cannot be found.
 34 */
 35export class ParameterNotFoundError extends DomainError {
 36  constructor(paramName: string) {
 037    super(`Parameter not found: ${paramName}`);
 038    this.paramName = paramName;
 39  }
 40
 41  readonly paramName: string;
 42}
 43
 44/**
 45 * Error thrown when AWS credentials or the security token are expired or invalid.
 46 */
 47export class ExpiredCredentialsError extends DomainError {
 48  readonly cause?: unknown;
 49
 50  constructor(cause?: unknown) {
 451    super(
 52      'AWS credentials are expired or invalid. Your security token or SSO ' +
 53        'session may have expired. Refresh your credentials and retry ' +
 54        '(for SSO, run: aws sso login).',
 55    );
 456    this.cause = cause;
 57  }
 58}
 59
 60/**
 61 * Error thrown when the AWS SSO session could not be resolved or loaded.
 62 */
 63export class SsoSessionExpiredError extends DomainError {
 64  readonly profileName?: string;
 65  readonly cause?: unknown;
 66
 67  constructor(profileName?: string, cause?: unknown) {
 1568    super(SsoSessionExpiredError.buildMessage(profileName));
 1569    this.profileName = profileName;
 1570    this.cause = cause;
 71  }
 72
 73  private static buildMessage(profileName?: string): string {
 1574    if (profileName) {
 1375      return (
 76        `Your AWS SSO session for profile '${profileName}' could not be ` +
 77        `loaded or has expired. Run: aws sso login --profile ${profileName} ` +
 78        'and then re-run this command.'
 79      );
 80    }
 281    return (
 82      'Your AWS SSO session could not be loaded or has expired. Run: ' +
 83      'aws sso login and then re-run this command.'
 84    );
 85  }
 86}
 87
 88/**
 89 * Describes a single secret that could not be resolved during a pull operation.
 90 */
 91export type SecretFetchFailure = {
 92  envVar: string;
 93  path: string;
 94  reason: string;
 95};
 96
 97/**
 98 * Error thrown when one or more secrets could not be fetched during a pull.
 99 */
 100export class SecretsFetchError extends DomainError {
 10101  constructor(readonly failures: ReadonlyArray<SecretFetchFailure>) {
 10102    super('Some secrets could not be fetched');
 103  }
 104}