@weave-js/core 0.12.0 → 0.12.1

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.
@@ -10,7 +10,7 @@ module.exports = (runtime) => {
10
10
  const wrapErrorHandlerMiddleware = function (handler) {
11
11
  return function errorHandlerMiddleware (context, serviceInjections) {
12
12
  return handler(context, serviceInjections)
13
- .catch(error => {
13
+ .catch((error) => {
14
14
  if (!(error instanceof Error)) {
15
15
  error = new WeaveError(error, 500);
16
16
  }
@@ -19,17 +19,49 @@ module.exports = (runtime) => {
19
19
  runtime.transport.removePendingRequestsById(context.id);
20
20
  }
21
21
 
22
- runtime.log.debug(`The action ${context.action.name} is rejected`, { requestId: context.id }, error);
22
+ Object.defineProperty(error, 'context', {
23
+ value: context,
24
+ writable: true,
25
+ enumerable: false
26
+ });
27
+
28
+ runtime.log.debug(`The action "${context.action.name}" was rejected`, { requestId: context.requestId }, error);
29
+ return runtime.handleError(error);
30
+ });
31
+ };
32
+ };
33
+
34
+ const wrapEventErrorHandlerMiddleware = function (handler) {
35
+ return function errorHandlerMiddleware (context, serviceInjections) {
36
+ return handler(context, serviceInjections)
37
+ .catch((error) => {
38
+ if (!(error instanceof Error)) {
39
+ error = new WeaveError(error, 500);
40
+ }
41
+
42
+ if (runtime.nodeId !== context.nodeId) {
43
+ runtime.transport.removePendingRequestsById(context.id);
44
+ }
45
+
46
+ Object.defineProperty(error, 'context', {
47
+ value: context,
48
+ writable: true,
49
+ enumerable: false
50
+ });
51
+
52
+ runtime.log.debug(`The event "${context.eventName}" was rejected`, { requestId: context.requestId }, error);
23
53
  return runtime.handleError(error);
54
+ })
55
+ .catch((error) => {
56
+ // we just log the error because we don't want to crash the event loop
57
+ runtime.log.error(error);
24
58
  });
25
- // .catch(error => {
26
- // runtime.log.error(error)
27
- // })
28
59
  };
29
60
  };
30
61
 
31
62
  return {
32
63
  localAction: wrapErrorHandlerMiddleware,
33
- remoteAction: wrapErrorHandlerMiddleware
64
+ remoteAction: wrapErrorHandlerMiddleware,
65
+ localEvent: wrapEventErrorHandlerMiddleware
34
66
  };
35
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weave-js/core",
3
- "version": "0.12.0",
3
+ "version": "0.12.1",
4
4
  "description": "The core package of weave",
5
5
  "keywords": [
6
6
  "Weave",
@@ -40,7 +40,7 @@
40
40
  "license": "MIT",
41
41
  "dependencies": {
42
42
  "@weave-js/errors": "^0.9.1",
43
- "@weave-js/utils": "^0.11.0",
43
+ "@weave-js/utils": "^0.11.1",
44
44
  "@weave-js/validator": "^0.12.0",
45
45
  "eventemitter2": "^6.4.5",
46
46
  "glob": "^7.2.0"
@@ -49,5 +49,5 @@
49
49
  "lib": "lib",
50
50
  "test": "test"
51
51
  },
52
- "gitHead": "406e96b1f3017cc1d22de6693f61a2265506c239"
52
+ "gitHead": "3f9662a98caa08d32ba5a181cc5871318aaece23"
53
53
  }