Pass a derived error in downloadLog

This commit is contained in:
tcely 2026-03-14 19:50:44 -04:00
parent a1d7c45f37
commit 3b562651f9
No known key found for this signature in database
GPG Key ID: 9F1DAF9D9070430F

View File

@ -18,9 +18,12 @@ function downloadLog(
prefix: string = "download-bun",
): void {
if (error instanceof Error) {
// Prepends your context to the error message without losing the Error object properties
error.message = `${prefix}: ${preface}: ${error.message}`;
f(error);
// Create a new Error so the original isn't mutated
const derived = new Error(`${prefix}: ${preface}: ${error.message}`, {
cause: error,
});
derived.stack = error.stack;
f(derived);
} else {
f(`${prefix}: ${preface}: ${String(error)}`);
}