• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dreamsparkx / node-ts-starter / 19901436386

03 Dec 2025 04:38PM UTC coverage: 80.13% (-0.4%) from 80.539%
19901436386

Pull #1352

github

Gaurav Bharti
fix(vitest): fixed vitest to latest version
Pull Request #1352: fix(vitest): fixed vitest to latest version

54 of 83 branches covered (65.06%)

Branch coverage included in aggregate %.

192 of 224 relevant lines covered (85.71%)

2.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.47
/src/util/error.ts
1
import logger from "./logger";
2

3
export class GeneralError extends Error {
4
  errors?: unknown[];
5
  constructor(message: string, errors?: unknown[]) {
6
    super(message);
8✔
7
    this.errors = errors;
8✔
8
  }
9
  /**
10
   * Returns status code of the type of error initialized
11
   * @returns status code of the type of error initialized
12
   */
13
  getCode() {
14
    if (this instanceof BadRequestError) {
8✔
15
      return 400;
4✔
16
    } else if (this instanceof UnAuthorizedRequestError) {
4✔
17
      return 401;
1✔
18
    } else if (this instanceof ForbiddenError) {
3✔
19
      return 403;
1✔
20
    } else if (this instanceof NotAcceptableError) {
2✔
21
      return 406;
1✔
22
    } else if (this instanceof ConflictError) {
1!
23
      return 409;
1✔
24
    } else if (this instanceof InternalServerError) {
×
25
      return 500;
×
26
    }
27
  }
28
}
29

30
export class ForbiddenError extends GeneralError {
31
  constructor(message: string, errors?: unknown[]) {
32
    super(message, errors);
1✔
33
  }
34
}
35

36
export class NotAcceptableError extends GeneralError {
37
  constructor(message: string) {
38
    super(message);
1✔
39
  }
40
}
41

42
export class ConflictError extends GeneralError {
43
  constructor(message: string) {
44
    super(message);
1✔
45
  }
46
}
47

48
export class BadRequestError extends GeneralError {
49
  constructor(message: string, errors?: unknown[]) {
50
    super(message, errors);
4✔
51
  }
52
}
53

54
export class InternalServerError extends GeneralError {
55
  constructor(
56
    message: string = "Internal Server Error",
×
57
    errors?: unknown[],
58
  ) {
59
    super(message);
×
60
    logger.error(message, errors);
×
61
  }
62
}
63

64
export class UnAuthorizedRequestError extends GeneralError {
65
  constructor(message: string) {
66
    super(message);
1✔
67
  }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc