aboutsummaryrefslogtreecommitdiff
path: root/apps/cf-ai-backend/src/errors/baseError.ts
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2024-08-06 11:20:29 -0700
committerGitHub <[email protected]>2024-08-06 11:20:29 -0700
commit7fc39cd770e4b2f55c6fdae1fa02fe0a66a93f6d (patch)
tree82e6a03099b50441c2fe9a9bf8e8ddf7afa293e5 /apps/cf-ai-backend/src/errors/baseError.ts
parentMerge pull request #219 from Deepakchowdavarapu/readme-issue (diff)
parentupdated kv and queues (diff)
downloadsupermemory-7fc39cd770e4b2f55c6fdae1fa02fe0a66a93f6d.tar.xz
supermemory-7fc39cd770e4b2f55c6fdae1fa02fe0a66a93f6d.zip
Merge pull request #193 from supermemoryai/kush/be-queue
Kush/be queue
Diffstat (limited to 'apps/cf-ai-backend/src/errors/baseError.ts')
-rw-r--r--apps/cf-ai-backend/src/errors/baseError.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/apps/cf-ai-backend/src/errors/baseError.ts b/apps/cf-ai-backend/src/errors/baseError.ts
new file mode 100644
index 00000000..0dcc2203
--- /dev/null
+++ b/apps/cf-ai-backend/src/errors/baseError.ts
@@ -0,0 +1,46 @@
+export class BaseHttpError extends Error {
+ public status: number;
+ public message: string;
+
+ constructor(status: number, message: string) {
+ super(message);
+ this.status = status;
+ this.message = message;
+ Object.setPrototypeOf(this, new.target.prototype); // Restore prototype chain
+ }
+ }
+
+
+ export class BaseError extends Error {
+ type: string;
+ message: string;
+ source: string;
+ ignoreLog: boolean;
+
+ constructor(
+ type: string,
+ message?: string,
+ source?: string,
+ ignoreLog = false
+ ) {
+ super();
+
+ Object.setPrototypeOf(this, new.target.prototype);
+
+ this.type = type;
+ this.message =
+ message ??
+ "An unknown error occurred. If this persists, please contact us.";
+ this.source = source ?? "unspecified";
+ this.ignoreLog = ignoreLog;
+ }
+
+ toJSON(): Record<PropertyKey, string> {
+ return {
+ type: this.type,
+ message: this.message,
+ source: this.source,
+ };
+ }
+ }
+ \ No newline at end of file