aboutsummaryrefslogtreecommitdiff
path: root/apps/backend/src/errors/baseError.ts
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2025-01-20 17:49:19 -0700
committerDhravya Shah <[email protected]>2025-01-20 17:50:45 -0700
commit47904011de646b92b1f3774f9a30bcfa118c5dc4 (patch)
treeab0e5e79c4ad5465ceeedc9b4015be2d9d01be45 /apps/backend/src/errors/baseError.ts
parentMerge pull request #295 from supermemoryai/extension/duplicate-save-fix (diff)
downloadsupermemory-47904011de646b92b1f3774f9a30bcfa118c5dc4.tar.xz
supermemory-47904011de646b92b1f3774f9a30bcfa118c5dc4.zip
Supermemory v2 Release 🚀
Diffstat (limited to 'apps/backend/src/errors/baseError.ts')
-rw-r--r--apps/backend/src/errors/baseError.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/backend/src/errors/baseError.ts b/apps/backend/src/errors/baseError.ts
new file mode 100644
index 00000000..bccc54df
--- /dev/null
+++ b/apps/backend/src/errors/baseError.ts
@@ -0,0 +1,45 @@
+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