25 lines
521 B
TypeScript
25 lines
521 B
TypeScript
export class DatabaseException implements Error {
|
|
name: string;
|
|
message: string;
|
|
|
|
constructor(
|
|
private _type: string = 'unknown',
|
|
private _code: string = '',
|
|
message?: string,
|
|
) {
|
|
this.name = 'DatabaseException';
|
|
this.message = message ?? 'An error occured with the database.';
|
|
if (this.message.includes('Unique constraint failed')) {
|
|
this.message = 'Already exists.';
|
|
}
|
|
}
|
|
|
|
get type(): string {
|
|
return this._type;
|
|
}
|
|
|
|
get code(): string {
|
|
return this._code;
|
|
}
|
|
}
|