You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
537 B
JavaScript

export default class ApiError extends Error {
status;
errors;
constructor(status, message, errors = []) {
super(message);
this.status = status;
this.errors = errors;
}
static UnauthorizedError() {
return new ApiError(401, 'Пользователь не авторизован')
}
static ForbiddenError() {
return new ApiError(403, 'Нет доступа')
}
static BadRequest(message, errors = []) {
return new ApiError(400, message, errors)
}
}