@gravity-ui/gateway 1.0.5 → 1.1.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @gravity-ui/gateway · [![npm package](https://img.shields.io/npm/v/@gravity-ui/gateway)](https://www.npmjs.com/package/@gravity-ui/gateway) [![CI](https://img.shields.io/github/actions/workflow/status/gravity-ui/gateway/.github/workflows/ci.yml?label=CI&logo=github)](https://github.com/gravity-ui/gateway/actions/workflows/ci.yml?query=branch:main)
2
2
 
3
- Express controller for working with REST/GRPC APIs
3
+ Express controller for working with REST/GRPC APIs.
4
4
 
5
5
  ## Install
6
6
 
@@ -45,17 +45,17 @@ function createMixedAction(config, api, serviceName, actionName, extra, ErrorCon
45
45
  }
46
46
  if (e instanceof Error) {
47
47
  const parsedError = (0, parse_error_1.parseMixedError)(e);
48
- ctx.logError('Request failed', ErrorConstructor.wrap(e), {
48
+ (0, common_1.handleError)(ErrorConstructor, e, ctx, 'Request failed', {
49
49
  actionName,
50
50
  serviceName,
51
- parsedError,
52
51
  });
53
52
  throw {
54
53
  error: parsedError,
55
54
  };
56
55
  }
56
+ (0, common_1.handleError)(ErrorConstructor, e, ctx, 'Request failed');
57
57
  throw {
58
- error: JSON.stringify(e),
58
+ error: e,
59
59
  };
60
60
  }
61
61
  finally {
@@ -43,8 +43,11 @@ function handleError(ErrorConstructor, error, ctx, message, extra) {
43
43
  if (error instanceof Error) {
44
44
  ctx.logError(message, ErrorConstructor.wrap(error), extra);
45
45
  }
46
+ else if (typeof error === 'string') {
47
+ ctx.logError(message, { error }, extra);
48
+ }
46
49
  else {
47
- ctx.logError(message, JSON.stringify(error), extra);
50
+ ctx.logError(message, error, extra);
48
51
  }
49
52
  }
50
53
  exports.handleError = handleError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/gateway",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "main": "build/index.js",