2018-01-15 11:55:31 +00:00
|
|
|
class BaseError extends Error {
|
2018-07-17 19:29:18 +00:00
|
|
|
constructor(statusCode, ...params) {
|
2018-02-21 09:43:21 +00:00
|
|
|
super(...params);
|
2018-07-17 19:29:18 +00:00
|
|
|
this.statusCode = statusCode;
|
2018-02-21 09:43:21 +00:00
|
|
|
}
|
2018-01-15 11:55:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class ValidationError extends BaseError {
|
2018-07-17 19:29:18 +00:00
|
|
|
constructor(...params) {
|
|
|
|
super(417, ...params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class NotFound extends BaseError {
|
|
|
|
constructor(...params) {
|
|
|
|
super(404, ...params);
|
|
|
|
}
|
2018-01-15 11:55:31 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 19:29:18 +00:00
|
|
|
class Forbidden extends BaseError {
|
|
|
|
constructor(...params) {
|
|
|
|
super(403, ...params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class ValueError extends ValidationError { }
|
|
|
|
class Conflict extends ValidationError { }
|
|
|
|
|
2018-01-15 11:55:31 +00:00
|
|
|
module.exports = {
|
2018-07-17 19:29:18 +00:00
|
|
|
ValidationError,
|
|
|
|
ValueError,
|
|
|
|
Conflict,
|
|
|
|
NotFound,
|
|
|
|
Forbidden
|
2018-01-15 11:55:31 +00:00
|
|
|
}
|