File size: 1,013 Bytes
8ba64ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
export class DomainError extends Error {
  constructor(
    public readonly userMessage: string,
    internalMessage?: string,
  ) {
    super(internalMessage ?? userMessage);
    this.name = "DomainError";
  }
}

export class GameNotFoundError extends DomainError {
  constructor(gameId: string) {
    super(
      "Game not found",
      `Game not found or corrupted state for gameId: ${gameId}`,
    );
    this.name = "GameNotFoundError";
  }
}

export class NotYourTurnError extends DomainError {
  constructor() {
    super("Not your turn");
    this.name = "NotYourTurnError";
  }
}

export class TimeExpiredError extends DomainError {
  constructor() {
    super("Time expired");
    this.name = "TimeExpiredError";
  }
}

export class IllegalMoveError extends DomainError {
  constructor() {
    super("Illegal move");
    this.name = "IllegalMoveError";
  }
}

export class AuthError extends DomainError {
  constructor(message = "Unauthorized") {
    super(message);
    this.name = "AuthError";
  }
}