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 }) } }