2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00
books/fyo/utils/errors.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
1.7 KiB
TypeScript
Raw Normal View History

2022-03-21 05:47:26 +00:00
export class BaseError extends Error {
message: string;
statusCode: number;
constructor(statusCode: number, message: string) {
super(message);
this.name = 'BaseError';
this.statusCode = statusCode;
this.message = message;
}
}
export class ValidationError extends BaseError {
constructor(message: string) {
super(417, message);
this.name = 'ValidationError';
}
}
export class NotFoundError extends BaseError {
constructor(message: string) {
super(404, message);
this.name = 'NotFoundError';
}
}
export class ForbiddenError extends BaseError {
constructor(message: string) {
super(403, message);
this.name = 'ForbiddenError';
}
}
export class DuplicateEntryError extends ValidationError {
constructor(message: string) {
super(message);
this.name = 'DuplicateEntryError';
}
}
export class LinkValidationError extends ValidationError {
constructor(message: string) {
super(message);
this.name = 'LinkValidationError';
}
}
export class MandatoryError extends ValidationError {
constructor(message: string) {
super(message);
this.name = 'MandatoryError';
}
}
export class DatabaseError extends BaseError {
constructor(message: string) {
super(500, message);
this.name = 'DatabaseError';
}
}
export class CannotCommitError extends DatabaseError {
constructor(message: string) {
super(message);
this.name = 'CannotCommitError';
}
}
2022-05-20 10:06:38 +00:00
export class NotImplemented extends BaseError {
constructor() {
super(501, '');
this.name = 'NotImplemented';
}
}
2022-03-21 05:47:26 +00:00
export class ValueError extends ValidationError {}
2022-04-25 06:33:31 +00:00
export class ConflictError extends ValidationError {}
2022-03-21 05:47:26 +00:00
export class InvalidFieldError extends ValidationError {}