From cdfa9286b8951b251acebbcbcc986d01e08c417c Mon Sep 17 00:00:00 2001 From: mshanemc Date: Fri, 5 Apr 2024 12:34:44 -0500 Subject: [PATCH] chore: no TypeError --- src/sfError.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/sfError.ts b/src/sfError.ts index 2c8fa524e..a59c23dd3 100644 --- a/src/sfError.ts +++ b/src/sfError.ts @@ -123,12 +123,16 @@ export class SfError extend const sfError = err instanceof Error ? // a basic error with message and name. We make it the cause to preserve any other properties - new SfError(err.message, err.name, undefined, err) + SfError.create({ + message: err.message, + name: err.name, + cause: err, + }) : // ok, something was throws that wasn't error or string. Convert it to an Error that preserves the information as the cause and wrap that. - SfError.wrap( - new TypeError(`SfError.wrap received type ${typeof err} but expects type Error or string`, { cause: err }) - ); - + SfError.create({ + message: `SfError.wrap received type ${typeof err} but expects type Error or string`, + cause: err, + }); // If the original error has a code, use that instead of name. if (hasString(err, 'code')) { sfError.code = err.code;