Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: wrap r19-specific errors with
R19Error
- Loading branch information
1 parent
f1c5dfd
commit bb88cad
Showing
5 changed files
with
183 additions
and
48 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,25 @@ | ||
type R19ErrorOptions = { | ||
procedurePath?: string[]; | ||
procedureArgs?: Record<string, unknown>; | ||
cause?: unknown; | ||
}; | ||
|
||
export class R19Error extends Error { | ||
procedurePath?: string[]; | ||
procedureArgs?: Record<string, unknown>; | ||
|
||
constructor(message: string, options: R19ErrorOptions = {}) { | ||
super(); | ||
|
||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, R19Error); | ||
} | ||
|
||
this.name = "R19Error"; | ||
this.message = message; | ||
this.cause = options.cause; | ||
|
||
this.procedurePath = options.procedurePath; | ||
this.procedureArgs = options.procedureArgs; | ||
} | ||
} |
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
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
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,17 @@ | ||
export const isPlainObject = ( | ||
value: unknown, | ||
): value is Record<PropertyKey, unknown> => { | ||
if (typeof value !== "object" || value === null) { | ||
return false; | ||
} | ||
|
||
const prototype = Object.getPrototypeOf(value); | ||
|
||
return ( | ||
(prototype === null || | ||
prototype === Object.prototype || | ||
Object.getPrototypeOf(prototype) === null) && | ||
!(Symbol.toStringTag in value) && | ||
!(Symbol.iterator in value) | ||
); | ||
}; |
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