@salesforce/core-bundle 8.2.2 → 8.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +17 -12
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -4611,7 +4611,7 @@ var require_package = __commonJS({
4611
4611
  "package.json"(exports2, module2) {
4612
4612
  module2.exports = {
4613
4613
  name: "@salesforce/core-bundle",
4614
- version: "8.2.2",
4614
+ version: "8.2.3",
4615
4615
  description: "Core libraries to interact with SFDX projects, orgs, and APIs.",
4616
4616
  main: "lib/index",
4617
4617
  types: "lib/index.d.ts",
@@ -9204,17 +9204,8 @@ var require_sfError = __commonJS({
9204
9204
  if (err instanceof _SfError) {
9205
9205
  return err;
9206
9206
  }
9207
- const sfError = err instanceof Error ? (
9208
- // a basic error with message and name. We make it the cause to preserve any other properties
9209
- _SfError.create({
9210
- message: err.message,
9211
- name: err.name,
9212
- cause: err
9213
- })
9214
- ) : (
9215
- // 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.
9216
- _SfError.wrap(new Error(`SfError.wrap received type ${typeof err} but expects type Error or string`, { cause: err }))
9217
- );
9207
+ const sfError = fromBasicError(err) ?? fromErrorLikeObject(err) ?? // something was thrown that wasn't error, error-like object or string. Convert it to an Error that preserves the information as the cause and wrap that.
9208
+ _SfError.wrap(new Error(`SfError.wrap received type ${typeof err} but expects type Error or string`, { cause: err }));
9218
9209
  if ((0, ts_types_1.hasString)(err, "code")) {
9219
9210
  sfError.code = err.code;
9220
9211
  }
@@ -9253,6 +9244,20 @@ var require_sfError = __commonJS({
9253
9244
  }
9254
9245
  };
9255
9246
  exports2.SfError = SfError;
9247
+ var fromBasicError = (err) => err instanceof Error ? SfError.create({ message: err.message, name: err.name, cause: err }) : void 0;
9248
+ var fromErrorLikeObject = (err) => {
9249
+ if (!err || typeof err !== "object") {
9250
+ return void 0;
9251
+ }
9252
+ if (!("message" in err)) {
9253
+ return void 0;
9254
+ }
9255
+ try {
9256
+ return SfError.create(err);
9257
+ } catch {
9258
+ return void 0;
9259
+ }
9260
+ };
9256
9261
  }
9257
9262
  });
9258
9263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/core-bundle",
3
- "version": "8.2.2",
3
+ "version": "8.2.3",
4
4
  "description": "Core libraries to interact with SFDX projects, orgs, and APIs.",
5
5
  "main": "lib/index",
6
6
  "types": "lib/index.d.ts",