@sipgate/integration-bridge 0.15.1 → 0.15.2
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/dist/util/error.d.ts +1 -1
- package/dist/util/error.js +11 -7
- package/dist/util/error.js.map +1 -1
- package/package.json +1 -1
package/dist/util/error.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { AxiosError } from "axios";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const throwAndDelegateError: (error: Error | AxiosError, source: string, apiKey?: string) => never;
|
package/dist/util/error.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.throwAndDelegateError = void 0;
|
|
4
4
|
const axios_1 = require("axios");
|
|
5
5
|
const models_1 = require("../models");
|
|
6
|
-
const
|
|
6
|
+
const logger_util_1 = require("./logger.util");
|
|
7
|
+
const throwAndDelegateError = (error, source, apiKey) => {
|
|
7
8
|
var _a, _b, _c;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
const message = error instanceof axios_1.AxiosError
|
|
10
|
+
? ((_a = error.response) === null || _a === void 0 ? void 0 : _a.data)
|
|
10
11
|
? JSON.stringify((_b = error.response) === null || _b === void 0 ? void 0 : _b.data)
|
|
11
|
-
: error.message
|
|
12
|
+
: error.message
|
|
13
|
+
: error.message;
|
|
14
|
+
(0, logger_util_1.errorLogger)(source, message, apiKey);
|
|
15
|
+
if (error instanceof axios_1.AxiosError) {
|
|
12
16
|
const status = ((_c = error.response) === null || _c === void 0 ? void 0 : _c.status) || 500;
|
|
13
17
|
var errorType;
|
|
14
18
|
switch (status) {
|
|
@@ -27,11 +31,11 @@ const generateError = (error, intentMessage) => {
|
|
|
27
31
|
errorType = models_1.IntegrationErrorType.INTEGRATION_ERROR_UNAVAILABLE;
|
|
28
32
|
break;
|
|
29
33
|
default:
|
|
30
|
-
throw new models_1.ServerError(status, `${
|
|
34
|
+
throw new models_1.ServerError(status, `${source} (${message})`);
|
|
31
35
|
}
|
|
32
36
|
throw new models_1.ServerError(models_1.DELEGATE_TO_FRONTEND_CODE, errorType);
|
|
33
37
|
}
|
|
34
38
|
throw new models_1.ServerError(500, "An internal error occurred");
|
|
35
39
|
};
|
|
36
|
-
exports.
|
|
40
|
+
exports.throwAndDelegateError = throwAndDelegateError;
|
|
37
41
|
//# sourceMappingURL=error.js.map
|
package/dist/util/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/util/error.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,sCAImB;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/util/error.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AACnC,sCAImB;AACnB,+CAA4C;AAErC,MAAM,qBAAqB,GAAG,CACnC,KAAyB,EACzB,MAAc,EACd,MAAe,EACf,EAAE;;IACF,MAAM,OAAO,GACX,KAAK,YAAY,kBAAU;QACzB,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI;YACpB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC;YACtC,CAAC,CAAC,KAAK,CAAC,OAAO;QACjB,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACpB,IAAA,yBAAW,EAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACrC,IAAI,KAAK,YAAY,kBAAU,EAAE;QAC/B,MAAM,MAAM,GAAG,CAAA,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,KAAI,GAAG,CAAC;QAC7C,IAAI,SAA+B,CAAC;QACpC,QAAQ,MAAM,EAAE;YACd,KAAK,GAAG;gBACN,SAAS,GAAG,6BAAoB,CAAC,yBAAyB,CAAC;gBAC3D,MA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