feat: Add base and early exit error classes

This commit is contained in:
Faruk AYDIN
2022-10-28 00:18:50 +02:00
parent 419d84da97
commit baebec2270
2 changed files with 20 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { IJSONObject } from '@automatisch/types';
export default class BaseError extends Error {
error = {};
constructor(error?: string | IJSONObject) {
super();
try {
this.error = JSON.parse(error as string);
} catch {
this.error = typeof error === 'string' ? { error } : error;
}
this.name = this.constructor.name;
}
}

View File

@@ -0,0 +1,3 @@
import BaseError from './base';
export default class EarlyExitError extends BaseError {}