/* eslint-disable max-classes-per-file */
export default class CustomError extends Error {
  code: string;

  constructor(code = 'GENERIC', ...params: any[]) {
    super(...params);

    if (Error.captureStackTrace) {
      Error.captureStackTrace(this, CustomError);
    }

    this.code = code;
  }
}

/**
 * NonRetryableError - Used for errors that should not be retried
 * Typical cases: configuration errors, missing data, validation failures
 */
export class NonRetryableError extends CustomError {
  nonRetryable: boolean = true;

  constructor(code: string, message: string) {
    super(code, message);
    this.name = 'NonRetryableError';
  }
}
