@lvce-editor/status-bar-worker 3.29.0 → 3.30.0

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.
@@ -1288,6 +1288,9 @@ const restoreExistingError = (error, currentStack) => {
1288
1288
  };
1289
1289
  const restoreMethodNotFoundError = (error, currentStack) => {
1290
1290
  const restoredError = new JsonRpcError(error.message);
1291
+ Object.assign(restoredError, {
1292
+ code: error.code
1293
+ });
1291
1294
  const parentStack = getParentStack(error);
1292
1295
  setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
1293
1296
  return restoredError;
@@ -1307,9 +1310,13 @@ const applyDataProperties = (restoredError, error) => {
1307
1310
  // @ts-ignore
1308
1311
  restoredError.codeFrame = error.data.codeFrame;
1309
1312
  }
1310
- if (error.data.code) {
1313
+ if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
1311
1314
  // @ts-ignore
1312
- restoredError.code = error.data.code;
1315
+ Object.defineProperty(restoredError, 'code', {
1316
+ configurable: true,
1317
+ value: error.data.code,
1318
+ writable: true
1319
+ });
1313
1320
  }
1314
1321
  if (error.data.type) {
1315
1322
  // @ts-ignore
@@ -1331,6 +1338,13 @@ const applyDirectProperties = (restoredError, error) => {
1331
1338
  };
1332
1339
  const restoreMessageError = (error, _currentStack) => {
1333
1340
  const restoredError = constructError(error.message, error.type, error.name);
1341
+ if (typeof error.code === 'string' || typeof error.code === 'number') {
1342
+ Object.defineProperty(restoredError, 'code', {
1343
+ configurable: true,
1344
+ value: error.code,
1345
+ writable: true
1346
+ });
1347
+ }
1334
1348
  if (error.data) {
1335
1349
  applyDataProperties(restoredError, error);
1336
1350
  } else {
@@ -1409,7 +1423,7 @@ const getErrorProperty = (error, prettyError) => {
1409
1423
  return {
1410
1424
  code: Custom,
1411
1425
  data: {
1412
- code: prettyError.code,
1426
+ code: prettyError.code ?? error?.code,
1413
1427
  codeFrame: prettyError.codeFrame,
1414
1428
  name: prettyError.name,
1415
1429
  stack: getStack(prettyError),
@@ -1446,7 +1460,12 @@ const getErrorResponseSimple = (id, error) => {
1446
1460
  return {
1447
1461
  error: {
1448
1462
  code: Custom,
1449
- data: error,
1463
+ data: error instanceof Error ? {
1464
+ ...error,
1465
+ code: 'code' in error ? error.code : undefined,
1466
+ stack: error.stack,
1467
+ type: error.name
1468
+ } : error,
1450
1469
  // @ts-ignore
1451
1470
  message: error.message
1452
1471
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",