fix: preserve error cause, fix test mock typing

- Add { cause: err } to thrown Error for upstream debugging
- Use 'as unknown as string' cast for undefined-id test mock
This commit is contained in:
Benedikt Schackenberg 2026-03-17 20:06:33 +00:00
parent cd0d45b184
commit ef9e8d0619
2 changed files with 2 additions and 2 deletions

View File

@ -646,7 +646,7 @@ describe("monitorDiscordProvider", () => {
const { monitorDiscordProvider } = await import("./provider.js");
const runtime = baseRuntime();
clientFetchUserMock.mockResolvedValueOnce({ id: undefined, username: "NoId" });
clientFetchUserMock.mockResolvedValueOnce({ id: undefined as unknown as string, username: "NoId" });
await expect(
monitorDiscordProvider({

View File

@ -884,7 +884,7 @@ export async function monitorDiscordProvider(opts: MonitorDiscordOpts = {}) {
// messages pass through), self-message filtering is disabled (risk of
// self-reply loops), and reply detection is broken. Let auto-restart
// retry instead of running in a degraded state. See #42219.
throw new Error(`discord: cannot start without bot identity: ${String(err)}`);
throw new Error(`discord: cannot start without bot identity: ${String(err)}`, { cause: err });
}
if (!botUserId) {
// fetchUser succeeded but returned no id — equally unsafe to continue.