@lvce-editor/json-rpc 4.0.0 → 4.1.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.
Files changed (2) hide show
  1. package/dist/index.js +23 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ class AssertionError extends Error {
19
19
  this.name = 'AssertionError';
20
20
  }
21
21
  }
22
- const getType = value => {
22
+ const getType$1 = value => {
23
23
  switch (typeof value) {
24
24
  case 'number':
25
25
  return 'number';
@@ -42,7 +42,7 @@ const getType = value => {
42
42
  }
43
43
  };
44
44
  const number = value => {
45
- const type = getType(value);
45
+ const type = getType$1(value);
46
46
  if (type !== 'number') {
47
47
  throw new AssertionError('expected value to be of type number');
48
48
  }
@@ -275,16 +275,17 @@ const unwrapJsonRpcResult = responseMessage => {
275
275
  throw new JsonRpcError('unexpected response message');
276
276
  };
277
277
 
278
- const create$1 = (message, error) => {
279
- return {
280
- jsonrpc: Two,
281
- id: message.id,
282
- error
283
- };
284
- };
285
-
286
278
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
287
279
 
280
+ const getType = prettyError => {
281
+ if (prettyError && prettyError.type) {
282
+ return prettyError.type;
283
+ }
284
+ if (prettyError && prettyError.constructor && prettyError.constructor.name) {
285
+ return prettyError.constructor.name;
286
+ }
287
+ return undefined;
288
+ };
288
289
  const getErrorProperty = (error, prettyError) => {
289
290
  if (error && error.code === E_COMMAND_NOT_FOUND) {
290
291
  return {
@@ -299,11 +300,21 @@ const getErrorProperty = (error, prettyError) => {
299
300
  data: {
300
301
  stack: prettyError.stack,
301
302
  codeFrame: prettyError.codeFrame,
302
- type: prettyError.type,
303
- code: prettyError.code
303
+ type: getType(prettyError),
304
+ code: prettyError.code,
305
+ name: prettyError.name
304
306
  }
305
307
  };
306
308
  };
309
+
310
+ const create$1 = (message, error) => {
311
+ return {
312
+ jsonrpc: Two,
313
+ id: message.id,
314
+ error
315
+ };
316
+ };
317
+
307
318
  const getErrorResponse = (message, error, preparePrettyError, logError) => {
308
319
  const prettyError = preparePrettyError(error);
309
320
  logError(error, prettyError);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/json-rpc",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "JsonRpc implementation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",