export class PosError extends Error {
  constructor(
    public readonly code: string,
    message: string,
  ) {
    super(message);
    this.name = 'PosError';
  }
}

export class StoreNotFoundError extends PosError {
  constructor(storeId: string) {
    super('STORE_NOT_FOUND', `Store not found: ${storeId}`);
  }
}

export class TerminalNotFoundError extends PosError {
  constructor(terminalId: string) {
    super('TERMINAL_NOT_FOUND', `Terminal not found: ${terminalId}`);
  }
}

export class CashSessionNotFoundError extends PosError {
  constructor(sessionId: string) {
    super('CASH_SESSION_NOT_FOUND', `Cash session not found: ${sessionId}`);
  }
}

export class CashSessionAlreadyOpenError extends PosError {
  constructor(terminalId: string) {
    super('SESSION_ALREADY_OPEN', `Terminal ${terminalId} already has an open session`);
  }
}

export class CashSessionNotOpenError extends PosError {
  constructor(terminalId: string) {
    super('SESSION_NOT_OPEN', `Terminal ${terminalId} has no open session`);
  }
}

export class TerminalNotBoundError extends PosError {
  constructor(terminalId: string) {
    super('TERMINAL_NOT_BOUND', `Terminal ${terminalId} is not bound`);
  }
}

export class TerminalDisabledError extends PosError {
  constructor(terminalId: string) {
    super('TERMINAL_DISABLED', `Terminal ${terminalId} is disabled`);
  }
}
