From 2496e09aeb53521a971bfa4c2265fe6342720799 Mon Sep 17 00:00:00 2001 From: David Snelling Date: Thu, 27 Aug 2026 12:07:09 -0700 Subject: [PATCH] fix(init): rethrow plugin activation failures with the original error as cause so the originating frame survives to the caller --- src/brainy.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/brainy.ts b/src/brainy.ts index b498e632..bfac8c08 100644 --- a/src/brainy.ts +++ b/src/brainy.ts @@ -1815,7 +1815,11 @@ export class Brainy implements BrainyInterface { if (error instanceof Error && (error as Error & { code?: string }).code === 'BRAINY_WRITER_LOCKED') { throw error } - throw new Error(`Failed to initialize Brainy: ${error}`) + // Wrap with the original as `cause` so the originating frame (a plugin's + // own file:line, e.g. a provider boot failure) survives to the caller's + // log — a plain string interpolation discards both stack and cause. + const message = error instanceof Error ? error.message : String(error) + throw new Error(`Failed to initialize Brainy: ${message}`, { cause: error }) } }