import type { CommonDomainErrorKind, DomainError } from '@core/shared/errors/DomainError';

export abstract class AdminDomainError extends Error implements DomainError<CommonDomainErrorKind> {
  readonly type = 'domain' as const;
  readonly context = 'admin-domain';
  abstract readonly kind: CommonDomainErrorKind;

  constructor(message: string) {
    super(message);
    Object.setPrototypeOf(this, new.target.prototype);
  }
}

export class AdminDomainValidationError
  extends AdminDomainError
  implements DomainError<'validation'>
{
  readonly kind = 'validation' as const;

  constructor(message: string) {
    super(message);
  }
}

export class AdminDomainInvariantError
  extends AdminDomainError
  implements DomainError<'invariant'>
{
  readonly kind = 'invariant' as const;

  constructor(message: string) {
    super(message);
  }
}

export class AuthorizationError
  extends AdminDomainError
  implements DomainError<'authorization'>
{
  readonly kind = 'authorization' as const;

  constructor(message: string) {
    super(message);
  }
}