All files / src/lib errors.js

100% Statements 8/8
100% Branches 5/5
100% Functions 6/6
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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    17x 17x           2x           6x           1x           7x           1x       5x              
class AppError extends Error {
  constructor(message, status) {
    super(message);
    this.status = status;
  }
}
 
class ValidationError extends AppError {
  constructor(message = "Invalid input") {
    super(message, 400);
  }
}
 
class UnauthorizedError extends AppError {
  constructor(message = "Unauthorized") {
    super(message, 401);
  }
}
 
class ForbiddenError extends AppError {
  constructor(message = "Forbidden") {
    super(message, 403);
  }
}
 
class NotFoundError extends AppError {
  constructor(message = "Not found") {
    super(message, 404);
  }
}
 
class ConflictError extends AppError {
  constructor(message = "Conflict") {
    super(message, 409);
  }
}
 
module.exports = {
  AppError,
  ValidationError,
  UnauthorizedError,
  ForbiddenError,
  NotFoundError,
  ConflictError,
};