Skip to content

Commit 003b00e

Browse files
committed
fix: update error classes to handle cause assignment for TypeScript compatibility
1 parent 6f6402f commit 003b00e

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/errors.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,15 @@ export class SensitiveInfoError extends Error {
7272
message: string,
7373
options?: { cause?: unknown }
7474
) {
75-
super(message, options)
75+
super(message)
7676
this.name = 'SensitiveInfoError'
7777
this.code = code
78+
// Assign `cause` directly instead of passing it to `super()` so this
79+
// compiles cleanly under TS configs whose `lib` predates ES2022 (where
80+
// the second `Error` constructor argument was introduced).
81+
if (options && 'cause' in options) {
82+
;(this as { cause?: unknown }).cause = options.cause
83+
}
7884
}
7985
}
8086

src/hooks/types.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ export class HookError extends Error {
3838
message: string,
3939
{ cause, operation, hint }: HookErrorOptions = {}
4040
) {
41-
super(message, { cause })
41+
super(message)
4242
this.name = 'HookError'
4343
this.operation = operation
4444
this.hint = hint
45+
// Assign `cause` directly instead of passing it to `super()` so this
46+
// compiles cleanly under TS configs whose `lib` predates ES2022 (where
47+
// the second `Error` constructor argument was introduced).
48+
if (cause !== undefined) {
49+
;(this as { cause?: unknown }).cause = cause
50+
}
4551
}
4652
}
4753

0 commit comments

Comments
 (0)