Skip to content

Commit 9419354

Browse files
committed
fix(objectql): declare cause on the fault error instead of passing it through super()
`pnpm --filter @objectstack/objectql typecheck` exited 2 on the previous commit: src/hook-withheld-readonly-fault.ts(140,20): error TS2554: Expected 0-1 arguments, but got 2. src/hook-withheld-readonly-fault.ts(140,31): error TS2304: Cannot find name 'ErrorOptions'. This repo compiles against `lib: ES2020`, where `Error` has neither a `cause` member nor the `ErrorOptions` constructor overload that carries one. The precedent is in this same package: `duplicate-record-error.ts` declares `readonly cause: unknown` on the class and assigns it by hand, and its comment already records why -- an undeclared assignment would be invisible to every TypeScript consumer of the field. Followed verbatim rather than reinvented. No behaviour change: the same original error is attached under the same name, and both suites plus the reverse verification were re-run against a forced rebuild after the edit. Claude-Session: https://claude.ai/code/session_01XTBcV7zZHmokdyQgXjbyEU Co-authored-by: Claude <noreply@anthropic.com>
1 parent e94f8ae commit 9419354

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/objectql/src/hook-withheld-readonly-fault.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,22 @@ export class HookWithheldReadonlyFaultError extends Error {
136136
readonly status = 400;
137137
/** The read-only keys the engine withheld from this hook, in payload order. */
138138
readonly withheldKeys: readonly string[];
139+
/**
140+
* The hook's original throw, whole.
141+
*
142+
* DECLARED on the class and assigned by hand rather than passed through the
143+
* constructor, for the reason `duplicate-record-error.ts` already writes down
144+
* one file over: this repo compiles against `lib: ES2020`, where `Error` has
145+
* neither a `cause` member nor an `ErrorOptions` overload to carry one — so
146+
* the two-argument `super()` does not compile, and an undeclared assignment
147+
* would be invisible to every TypeScript consumer of the field.
148+
*/
149+
readonly cause: unknown;
139150
constructor(message: string, withheldKeys: readonly string[], options?: { cause?: unknown }) {
140-
super(message, options as ErrorOptions);
151+
super(message);
141152
this.name = 'HookWithheldReadonlyFaultError';
142153
this.withheldKeys = withheldKeys;
154+
this.cause = options?.cause;
143155
}
144156
}
145157

0 commit comments

Comments
 (0)