Pass a derived error in downloadLog
This commit is contained in:
parent
a1d7c45f37
commit
3b562651f9
@ -18,9 +18,12 @@ function downloadLog(
|
|||||||
prefix: string = "download-bun",
|
prefix: string = "download-bun",
|
||||||
): void {
|
): void {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
// Prepends your context to the error message without losing the Error object properties
|
// Create a new Error so the original isn't mutated
|
||||||
error.message = `${prefix}: ${preface}: ${error.message}`;
|
const derived = new Error(`${prefix}: ${preface}: ${error.message}`, {
|
||||||
f(error);
|
cause: error,
|
||||||
|
});
|
||||||
|
derived.stack = error.stack;
|
||||||
|
f(derived);
|
||||||
} else {
|
} else {
|
||||||
f(`${prefix}: ${preface}: ${String(error)}`);
|
f(`${prefix}: ${preface}: ${String(error)}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user