-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1bab50
commit 0f31a95
Showing
3 changed files
with
71 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export class CustomError extends Error { | ||
constructor( | ||
message: string, | ||
public readonly code: number, | ||
public readonly metadata: Record<string, unknown> | ||
) { | ||
super(message) | ||
this.name = 'CustomError' | ||
} | ||
} | ||
|
||
// export class CustomErrorWithMethod extends CustomError { | ||
// logError() { | ||
// console.error(`[${this.code}] ${this.message}`) | ||
// } | ||
// } | ||
|
||
// export class CustomErrorWithMethodAndType extends CustomError { | ||
// logError(): void { | ||
// console.error(`[${this.code}] ${this.message}`) | ||
// } | ||
|
||
// getError(): Error { | ||
// return this | ||
// } | ||
// } | ||
|
||
// export class CustomErrorWithMethodAndTypeAndReturn { | ||
// constructor( | ||
// private message: string, | ||
// public readonly code: number, | ||
// public readonly metadata: Record<string, unknown> | ||
// ) { | ||
// this.message = message | ||
// this.code = code | ||
// this.metadata = metadata | ||
// } | ||
|
||
// logError(): void { | ||
// console.error(`[${this.code}] ${this.message}`) | ||
// } | ||
|
||
// getError(): Error { | ||
// return new Error(this.message) | ||
// } | ||
// } | ||
|
||
// export class Result<T, E extends Error> { | ||
// constructor( | ||
// readonly value: T | null = null, | ||
// readonly error: E | null = null | ||
// ) {} | ||
|
||
// isOk(): this is { readonly value: T } { | ||
// return this.value !== null && this.error === null; | ||
// } | ||
|
||
// isErr(): this is { readonly error: E } { | ||
// return this.error !== null && this.value === null; | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export declare class CustomError extends Error { | ||
constructor( | ||
message: string, | ||
public readonly code: number, | ||
public readonly metadata: Record<string, unknown> | ||
) { | ||
super(message) | ||
this.name = 'CustomError' | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.