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

23 lines
657 B
JavaScript
Raw Normal View History

class BaseError extends Error {
2018-02-21 09:43:21 +00:00
constructor(status_code, ...params) {
super(...params);
this.status_code = status_code;
}
}
class ValidationError extends BaseError {
2018-02-21 09:43:21 +00:00
constructor(...params) { super(417, ...params); }
}
module.exports = {
2018-02-21 09:43:21 +00:00
ValidationError: ValidationError,
ValueError: class ValueError extends ValidationError { },
Conflict: class Conflict extends ValidationError { },
2018-02-21 09:43:21 +00:00
NotFound: class NotFound extends BaseError {
constructor(...params) { super(404, ...params); }
},
Forbidden: class Forbidden extends BaseError {
constructor(...params) { super(403, ...params); }
},
}