2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00
books/common/errors.js

36 lines
655 B
JavaScript
Raw Normal View History

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
}
}
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-07-17 19:29:18 +00:00
class Forbidden extends BaseError {
constructor(...params) {
super(403, ...params);
}
}
class ValueError extends ValidationError { }
class Conflict extends ValidationError { }
module.exports = {
2018-07-17 19:29:18 +00:00
ValidationError,
ValueError,
Conflict,
NotFound,
Forbidden
}